69 $defaultClass =
'db_table_'.$this->cfg->name;
70 if (get_class($this) != $defaultClass)
71 $this->cfg->overload($defaultClass);
72 $this->rawName = $this->cfg->db->prefixTable($this->cfg->name);
86 $this->i18nTable =
db::get(
'table', $i18ntable, array(
108 return !is_null($this->i18nTable);
127 if ($this->i18nTable) {
128 foreach($this->i18nTable->getField() as
$f) {
140 $this->fields = $this->
getDb()->fields($this->cfg->name);
141 $this->cols = array_keys($this->fields);
143 if (array_key_exists($this->cfg->inserted, $this->fields))
144 $this->fields[$this->cfg->inserted][
'auto'] =
true;
146 if (array_key_exists($this->cfg->updated, $this->fields))
147 $this->fields[$this->cfg->updated][
'auto'] =
true;
149 if (array_key_exists($this->cfg->deleted, $this->fields))
150 $this->fields[$this->cfg->deleted][
'auto'] =
true;
152 if ($this->cfg->check(
'fields') && is_array($this->cfg->fields) && !empty($this->cfg->fields)) {
153 factory::mergeCfg($this->fields, array_intersect_key($this->cfg->fields, $this->fields));
154 foreach($this->fields as &
$f) {
155 if (is_array($f[
'default']))
156 $f[
'default'] = array_key_exists(1, $f[
'default']) ? $f[
'default'][1] : $f[
'default'][0];
165 if (empty($this->cfg->primary)) {
167 foreach($this->fields as $n=>&
$f)
169 $primary[
$f[
'primaryPos']] = $n;
170 if ($f[
'identity']) {
171 $this->cfg->ident = $n;
174 $this->cfg->primary = $primary;
175 }
else if(is_string($this->cfg->primary))
176 $this->cfg->primary = array($this->cfg->primary);
183 if ($this->linkedTables === null && !$this->
isI18n()) {
184 $this->linkedTables = array();
185 $this->linkedTableNames = array();
186 foreach($this->cols as $c) {
187 if (strpos($c,
'_') && $this->fields[$c][
'type'] !=
'file') {
188 $tmp = explode(
'_', $c);
189 $num = is_numeric($tmp[0])? array_shift($tmp) : 1;
190 $table = array_shift($tmp);
192 $i18nFields = array();
193 foreach($tmp as $t) {
200 $sep = $this->cfg->defSep;
204 if (!empty($this->fields[$c][
'comment'])) {
205 $com = $this->fields[$c][
'comment'];
206 foreach($com as $kk=>$cc) {
207 if (!is_numeric($kk)) {
212 $sep = !empty($com[0])? array_shift($com) : $this->cfg->defSep;
213 $list = array(array_shift($com));
214 $nbFieldGr = array_shift($com);
215 $sepGr = array_shift($com);
217 $this->linkedTableNames[$c] = $table;
218 $this->linkedTables[$c] = array_merge(array(
221 'ident'=>$this->cfg->defId,
222 'fields'=>implode(
',',
$fields),
223 'i18nFields'=>implode(
',', $i18nFields),
224 'label'=>ucfirst($table),
228 'nbFieldGr'=>$nbFieldGr,
236 if ($this->cfg->check(
'linked') && is_array($this->cfg->linked) && !empty($this->cfg->linked))
246 return $this->cfg->db;
256 return $this->
getDb()->getWhere($prm);
266 return is_array($this->linkedTables) && array_key_exists($field, $this->linkedTables);
276 if (is_array($this->linkedTableNames)) {
277 $key = array_search($tablename, $this->linkedTableNames);
295 return $this->linkedTables[$field];
307 if (!array_key_exists(
'tableObj', $link))
308 $link[
'tableObject'] =
db::get(
'table', $link[
'table'], array(
311 return $link[
'tableObject'];
325 return $table->getRow($data,
false, array(
'needReload'=>
true));
333 if (is_null($this->relatedTables)) {
334 $this->relatedTables = array();
335 $search = $this->rawName.
'_';
336 $tables = $this->
getDb()->getTablesWith(array(
'start'=>$search));
337 foreach($tables as $t) {
338 $relatedTable = substr($t, strlen($search));
339 $table =
db::get(
'table', $t, array(
345 if (is_null($fk1) && strpos($k, $this->rawName) !==
false) {
346 $fk1 = array_merge($v, array(
'link'=>$table->getLinked($k)));
348 }
else if (strpos($k, $relatedTable) !==
false) {
349 $fk2 = array_merge($v, array(
'link'=>$table->getLinked($k)));
354 $this->relatedTables[$t] = array(
357 'table'=>$relatedTable,
364 if ($this->cfg->check(
'related') && is_array($this->relatedTables) && !empty($this->relatedTables))
389 return $this->
isRelated($name)? $this->relatedTables[$name] : null;
401 return $table->getRow($data);
413 return $related[
'tableObj'];
425 $shouldStart = $this->
getName().
'_';
426 $pos = strpos($name, $shouldStart);
427 if ($pos !== 0 && $add)
428 $name = $shouldStart.$name;
429 else if ($pos === 0 && !$add)
430 $name = substr($name, strlen($shouldStart));
441 if (is_null($this->targetingTables)) {
443 if ($this->cfg->cacheEnabled) {
444 $cache = $this->
getDb()->getCache();
445 $cache->get($this->targetingTables, array(
'id'=>$tblName));
448 if (is_null($this->targetingTables)) {
449 $this->targetingTables = array();
450 foreach($this->
getDb()->getTables() as $tbl) {
452 $this->targetingTables[] = $tbl;
453 $tmpPos = strpos($tbl, $tblName.
'_');
455 $this->targetingTables[] = substr($tbl, strlen($tblName)+1);
458 if ($this->cfg->cacheEnabled)
472 if (strpos($this->
getName(),
'_') !==
false) {
473 $tmp = explode(
'_', $this->
getName());
474 if ($tmp[0] == $tableName || $tmp[1] == $tableName)
480 if ($linked[
'table'] == $tableName)
500 $cfgLabel = $this->cfg->label;
501 foreach($this->cols as $c) {
502 if (array_key_exists($c, $cfgLabel) && $label = $cfgLabel[$c]) {
504 unset($cfgLabel[$c]);
505 }
else if($this->fields[$c][
'type'] ==
'file')
506 $labels[$c] = ucwords(str_replace(
'_',
' ', strtolower(substr($c, 0, -5))));
509 $pos = strpos($c,
'_');
514 $pos = strpos($c,
'_', $start) - $start;
516 $use = substr($c, $start, $pos);
518 $labels[$c] = ucwords(strtolower($use));
520 $this->fields[$c][
'label'] = $labels[$c];
522 foreach($this->relatedTables as $r) {
523 if (array_key_exists($r[
'table'], $cfgLabel) && $label = $cfgLabel[$r[
'table']]) {
525 unset($cfgLabel[$r[
'table']]);
527 $labels[$r[
'table']] = ucwords(str_replace(
'_',
' ', strtolower($r[
'table'])));
529 $this->cfg->label = array_merge($labels, $cfgLabel);
543 return $this->cfg->label;
546 return $this->cfg->getInArray(
'label', $field);
556 return $this->i18nTable->getLabel($field);
566 public function getField($field = null, $keyVal = null) {
570 $ret = array_key_exists($field, $this->fields) ? $this->fields[$field] : null;
571 if (!is_null($keyVal) && is_array($ret) && array_key_exists($keyVal, $ret))
572 return $ret[$keyVal];
573 return $ret ? $ret : $this->cfg->getInArray(
'label', $field);
583 foreach($this->fields as
$f) {
584 if ($f[
'type'] ==
'file')
605 return $this->cfg->name;
623 return $this->cfg->ident;
632 return $this->cfg->primary;
646 $ret = $this->
getDb()->insert(array(
647 'table'=>$this->rawName,
666 $ret = $this->
getDb()->replace(array(
667 'table'=>$this->rawName,
683 public function update(array $data, $where = null) {
685 $ret = $this->
getDb()->update(array(
686 'table'=>$this->rawName,
702 public function delete($where = null) {
708 $rows = $this->
select(array(
'autoJoin'=>
false,
'where'=>$where));
709 if ($this->cfg->deleteCheckFile) {
711 foreach($rows as $r) {
712 foreach($files as
$f) {
713 if (!isset(
$fields[$f.
'-'.$r->get($f)])) {
714 $form = $r->getForm(array($f));
715 $fields[$f.
'-'.$r->get($f)] = array(
716 'formValue'=>$form->get($f)->getRawValue(),
717 'exist'=>$this->
count(array(
'autoJoin'=>
false,
'where'=>array($f=>$r->get($f)))),
721 $fields[$f.
'-'.$r->get($f)][
'delete']++;
725 if ($f[
'exist'] == $f[
'delete'])
726 $f[
'formValue']->delete();
729 foreach($rows as $r) {
730 $form = $r->getForm($files);
731 foreach($files as
$f)
732 $form->get($f)->getRawValue()->delete();
736 $ret = $this->
getDb()->delete(array(
737 'table'=>$this->rawName,
739 'optim'=>$this->cfg->optimAfterDelete
742 $ret = $this->
getDb()->update(array(
743 'table'=>$this->rawName,
746 'optim'=>$this->cfg->optimAfterDelete
762 if ($fieldName = $this->cfg->get($type)) {
763 if (array_key_exists($fieldName, $this->fields) && !array_key_exists($fieldName, $data)) {
764 $data[$fieldName] = $this->
dateValue($this->fields[$fieldName][
'type']);
781 $ret = date(
'Y-m-d');
784 $ret = date(
'Y-m-d H:i:s');
799 public function select(array $prm = array()) {
803 $cache = $this->
getDb()->getCache();
804 $canCache = $this->cfg->cacheEnabled && (!isset($prm[
'order']) || !(stripos($prm[
'order'],
'rand(') !==
false));
805 if (!$canCache || !$cache->get($ret, array(
'id'=>$this->
getName().
'-'.sha1(serialize($prm).
'-'.serialize($tmpTables))))) {
806 $ret = $this->
getDb()->select($prm);
808 if (!empty($ret) && !empty($this->cfg->forceValues)) {
809 foreach($ret as $k=>$v)
810 $ret[$k] = array_merge($v, $this->cfg->forceValues);
813 self::parseLinked($ret, $tmpTables);
819 if (array_key_exists(
'first', $prm) && $prm[
'first']) {
821 return db::get(
'row', $this, array(
822 'db'=>$this->
getDb(),
828 return db::get(
'rowset', $this, array(
829 'db'=>$this->
getDb(),
843 $prm[
'group'] = $prm[
'fields'] = $this->rawName.
'.'.$this->
getIdent();
845 $prm[
'group'] = $prm[
'fields'] = $this->rawName.
'.'.implode(
','.$this->rawName.
'.', $this->getPrimary());
847 $prm[
'where'] = $this->
getDb()->makeWhere($prm[
'where'], $prm[
'whereOp'],
false);
848 $nb = array_key_exists(
'join', $prm) ?
count($prm[
'join']) : 0;
849 for($i=0; $i<$nb; $i++) {
850 $table = array_key_exists(
'alias', $prm[
'join'][$i])
851 ? $prm[
'join'][$i][
'alias']
852 : $prm[
'join'][$i][
'table'];
853 if (array_key_exists(
'dir', $prm[
'join'][$i]) &&
854 !is_null(strpos($prm[
'join'][$i][
'dir'],
'outer')) &&
855 !preg_match(
'/`'.$table.
'`\./', $prm[
'where']))
856 unset($prm[
'join'][$i]);
858 return $this->
getDb()->count($prm);
872 'autoJoin'=>$this->cfg->autoJoin,
875 if (is_array($prm[
'where'])) {
876 foreach($prm[
'where'] as $k=>$v) {
877 if (!is_numeric($k) && strpos($k,
'.') ===
false) {
878 $newK = $this->rawName.
'.'.$k;
879 if (!array_key_exists($newK, $prm[
'where'])) {
880 $prm[
'where'][$newK] = $v;
881 unset($prm[
'where'][$k]);
885 }
else if (!empty($prm[
'where']) && !is_array($prm[
'where']) && !is_object($prm[
'where'])
886 && (strpos($prm[
'where'],
'=') ===
false && strpos($prm[
'where'],
'<') ===
false 887 && strpos($prm[
'where'],
'>') ===
false && stripos($prm[
'where'],
'LIKE') ===
false 888 && stripos($prm[
'where'],
'IN') ===
false)) {
889 $prm[
'where'] = $this->rawName.
'.'.$this->cfg->ident.
'='.$prm[
'where'];
892 $prm = array_merge(array(
893 'fields'=>$this->
getDb()->quoteIdentifier($this->rawName).
'.*',
894 'table'=>$this->rawName,
897 if (is_array($prm[
'fields'])) {
898 array_walk($prm[
'fields'],
899 create_function(
'&$v',
'$v = strpos($v, ".") === false? "'.$this->rawName.
'.".$v: $v;'));
900 $prm[
'fields'] = implode(
',', $prm[
'fields']);
903 $join = isset($prm[
'join']) ? $prm[
'join'] : array();
904 $prm[
'join'] = array();
905 $tmpTables = array();
906 if (!empty($this->linkedTables) && $prm[
'autoJoin']) {
907 foreach($this->linkedTables as
$f=>$p) {
909 $prm[
'join'][] = array(
910 'table'=>$p[
'table'],
913 'on'=>$this->rawName.
'.'.
$f.
'='.$alias.
'.'.$p[
'ident']
915 $fields = explode(
',', $p[
'fields']);
916 array_unshift(
$fields, $p[
'ident']);
919 array_walk($fieldsT, create_function(
'&$v',
'$v = "'.$alias.
'_".$v;'));
920 $tmpTables[
$f] = $fieldsT;
921 $tmpTables[
$f][
'sep'] = $p[
'sep'];
922 $tmpTables[
$f][
'ident'] = $alias.
'_'.$p[
'ident'];
924 $linkedTable =
db::get(
'table', $p[
'table'], array(
928 if ($linkedInfo = $linkedTable->getLinkedTableName($t)) {
929 $aliasT = $alias.
'_'.$linkedInfo[
'table'];
930 $prm[
'join'][] = array(
931 'table'=>$linkedInfo[
'table'],
934 'on'=>$alias.
'.'.$linkedInfo[
'field'].
'='.$aliasT.
'.'.$linkedInfo[
'ident']
937 foreach(explode(
',', $linkedInfo[
'fields']) as $tt) {
938 $ttmp[] = $aliasT.
'.'.$tt;
939 $ttmp[] =
'"'.$linkedInfo[
'sep'].
'"';
942 $tmp[] =
'CONCAT('.implode(
',', $ttmp).
') AS '.$alias.
'_'.$t;
944 $tmp[] = $alias.
'.'.$t.
' AS '.$alias.
'_'.$t;
947 $prm[
'fields'].=
','.implode(
',',
$fields);
949 if ($p[
'i18nFields']) {
950 $fieldsI18n = array();
951 $i18nTableName = $p[
'table'].db::getCfg(
'i18n');
954 $i18nAlias = $alias.db::getCfg(
'i18n');
955 $prm[
'join'][] = array(
956 'table'=>$i18nTableName,
959 'on'=>$alias.
'.'.$p[
'ident'].
'='.$i18nAlias.
'.'.$primary[0].
960 ' AND '.$i18nAlias.
'.'.$primary[1].
'="'.
request::get(
'lang').
'"' 962 $fields = explode(
',', $p[
'i18nFields']);
965 array_walk($fieldsI18n, create_function(
'&$v',
'$v = "'.$alias.
'_'.
db::getCfg(
'i18n').
'".$v;'));
966 array_walk(
$fields, create_function(
'&$v',
'$v = "'.$i18nAlias.
'.".$v." AS ' 968 $tmpTables[
$f] = array_merge($tmpTables[
$f], $fieldsI18n);
970 $prm[
'fields'].=
','.implode(
',',
$fields);
975 if ((!empty($this->relatedTables) && $prm[
'autoJoin']) || $this->i18nTable) {
976 foreach($this->relatedTables as
$f=>$p) {
977 $prm[
'join'][] = array(
980 'on'=>$this->rawName.
'.'.$p[
'fk1'][
'link'][
'ident'].
'='.
$f.
'.'.$p[
'fk1'][
'name']
984 $fields = array_keys($p[
'fields']);
986 array_walk($fieldsTableLink, create_function(
'&$v',
'$v = "'.
$f.
'_".$v;'));
987 array_walk(
$fields, create_function(
'&$v',
'$v = "'.
$f.
'.".$v." AS '.
$f.
'_".$v;'));
989 $prm[
'fields'].=
','.implode(
',',
$fields);
991 $prm[
'join'][] = array(
992 'table'=>$p[
'table'],
994 'on'=>
$f.
'.'.$p[
'fk2'][
'name'].
'='.$p[
'table'].
'.'.$p[
'fk2'][
'link'][
'ident']
998 $fields = explode(
',', $p[
'fk2'][
'link'][
'fields']);
999 array_unshift(
$fields, $p[
'fk2'][
'link'][
'ident']);
1002 array_walk($fieldsT, create_function(
'&$v',
'$v = "'.$p[
'table'].
'_".$v;'));
1003 array_walk(
$fields, create_function(
'&$v',
'$v = "'.$p[
'table'].
'.".$v." AS '.$p[
'table'].
'_".$v;'));
1005 $prm[
'fields'].=
','.implode(
',',
$fields);
1008 if ($p[
'fk2'][
'link'][
'i18nFields']) {
1009 $fieldsI18n = array();
1010 $i18nTableName = $p[
'table'].db::getCfg(
'i18n');
1013 $prm[
'join'][] = array(
1014 'table'=>$i18nTableName,
1015 'dir'=>
'left outer',
1016 'on'=>
$f.
'.'.$p[
'fk2'][
'name'].
'='.$i18nTableName.
'.'.$primary[0].
1017 ' AND '.$i18nTableName.
'.'.$primary[1].
'="'.
request::get(
'lang').
'"' 1019 $fields = explode(
',', $p[
'fk2'][
'link'][
'i18nFields']);
1022 array_walk($fieldsI18n, create_function(
'&$v',
'$v = "'.$i18nTableName.
'_".$v;'));
1023 array_walk(
$fields, create_function(
'&$v',
'$v = "'.$i18nTableName.
'.".$v." AS ' 1024 .$p[
'table'].
'_'.
db::getCfg(
'i18n').
'".$v;'));
1026 $prm[
'fields'].=
','.implode(
',',
$fields);
1029 $tmpTables[
'relatedTable'][
$f] = array(
1031 'tableName'=>$p[
'table'],
1032 'tableLink'=>$fieldsTableLink,
1033 'table'=>array_merge($fieldsT, array(
1034 'field'=>$p[
'fk2'][
'name'],
1035 'sep'=>$p[
'fk2'][
'link'][
'sep'],
1036 'ident'=>$p[
'table'].
'_'.$p[
'fk2'][
'link'][
'ident'],
1040 if ($this->i18nTable) {
1041 $i18nName = $this->i18nTable->getName();
1042 $primary = $this->i18nTable->getPrimary();
1043 $prm[
'join'][] = array(
1045 'dir'=>
'left outer',
1046 'on'=>$this->rawName.
'.'.$this->getIdent().
'='.$i18nName.
'.'.$primary[0]
1052 $fields[] = $f[
'name'];
1055 array_walk($fieldsTableLink, create_function(
'&$v',
'$v = "'.$i18nName.
'_".$v;'));
1056 array_walk($fields, create_function(
'&$v',
'$v = "'.$i18nName.
'.".$v." AS '.$i18nName.
'_".$v;'));
1058 if (!empty($fields))
1059 $prm[
'fields'].=
','.implode(
',', $fields);
1062 $tmpTables[
'relatedTable'][$i18nName] = array(
1064 'tableName'=>$i18nName,
1065 'tableLink'=>$fieldsTableLink,
1067 'field'=>$i18nName.
'_'.$primary[0],
1069 'ident'=>$i18nName.
'_'.$primary[1],
1073 if (array_key_exists(
'nb', $prm)) {
1074 $tmpTables[
'nb'] = $prm[
'nb'];
1075 $tmpTables[
'st'] = array_key_exists(
'start', $prm)? $prm[
'start'] : 0;
1080 $prm[
'join'] = array_merge($prm[
'join'], $join);
1092 if (!empty($linked) && !empty($data)) {
1093 if (array_key_exists(
'relatedTable', $linked)) {
1096 $tmpRelated = array();
1101 $idRelated = array();
1103 for($i = 0; $i<$nb; $i++) {
1104 $id = $data[$i][$ident];
1107 if (!array_key_exists($id, $ids)) {
1110 $ids[$id] = $current;
1111 $data[$current][
'related'] = array();
1114 $current = $ids[$id];
1115 foreach($linked[
'relatedTable'] as $t=>$r) {
1116 if (!array_key_exists($r[
'tableName'], $data[$current][
'related']))
1117 $data[$current][
'related'][$r[
'tableName']] = array();
1118 if (!$data[$i][$r[
'table'][
'ident']]
1119 || (array_key_exists($id, $idRelated)
1120 && array_key_exists($r[
'tableName'], $idRelated[$id])
1121 && in_array($data[$i][$r[
'table'][
'ident']], $idRelated[$id][$r[
'tableName']])))
1128 foreach($r[
'table'] as $kk=>$fTab) {
1129 if ($kk !=
'sep' && $kk !=
'ident' && $kk !=
db::getCfg(
'i18n')) {
1130 if (!empty($data[$i][$fTab]))
1131 $label[] = $data[$i][$fTab];
1132 if ($fTab != $r[
'table'][
'ident'])
1133 unset($data[$i][$fTab]);
1136 if (!empty($label)) {
1137 $tmp[substr($r[
'table'][
'ident'], strlen($r[
'tableName'])+1)] = $data[$i][$r[
'table'][
'ident']];
1138 $tmp[$r[
'table'][
'field']] = implode($r[
'table'][
'sep'], $label);
1140 $idRelated[$id][$r[
'tableName']][] = $data[$i][$r[
'table'][
'ident']];
1142 foreach($r[
'tableLink'] as $tl) {
1143 $tmp[substr($tl, strlen($t)+1)] = $data[$i][$tl];
1144 unset($data[$i][$tl]);
1148 $data[$current][
'related'][$r[
'tableName']][] = $tmp;
1155 $data = array_merge($data);
1157 unset($linked[
'relatedTable']);
1159 if (array_key_exists(
'nb', $linked)) {
1160 $data = array_slice($data, $linked[
'st'], $linked[
'nb']);
1161 unset($linked[
'nb']);
1162 unset($linked[
'st']);
1167 array_walk($data, create_function(
'&$v, $i, &$tl',
' 1168 $v["'.$linkedKey.
'"] = array(); 1169 foreach($tl as $k=>$t) { 1170 $v["'.$linkedKey.
'"][$k] = array(); 1172 $length = strlen($k)+1; 1173 foreach($t as $kk=>$f) { 1174 if ($kk != "sep" && $kk != "ident") { 1177 $v["'.$linkedKey.
'"][$k][substr($f, $length)] = $v[$f]; 1178 if ($f != $t["ident"]) 1182 if (array_key_exists($t["ident"], $v) && $v[$t["ident"]]) { 1183 $ident = substr($t["ident"], $length); 1184 $v["'.$linkedKey.
'"][$k][$ident] = $v[$t["ident"]]; 1185 $v[$k] = $v["'.$linkedKey.
'"][$k]["label"] = implode($t["sep"], $label); 1188 $v["'.$linkedKey.
'"][$k] = array(); 1202 return $this->
select(array(
1219 foreach($this->fields as &
$f)
1221 $filter[] = $f[
'name'];
1222 }
else if (!is_array($filter))
1223 $filter = explode(
',', $filter);
1225 $where = $this->
getWhere(array(
'op'=>
'OR'));
1226 foreach($filter as
$f)
1229 'val'=>
'%'.$text.
'%',
1237 return $this->
select($prm);
1247 if (is_null($field))
1249 $query =
'SELECT MIN('.$field.
'),MAX('.$field.
') FROM '.$this->
getRawName()
1250 .
' WHERE '.$this->cfg->whereRange;
1251 $tmp = $this->
getDb()->query($query)->fetchAll(PDO::FETCH_NUM);
1253 $min = array_key_exists(0, $tmp) ? $tmp[0] : 0;
1256 'max'=>array_key_exists(1, $tmp) ? $tmp[1] : $min,
1267 if (is_null($clearTargeting))
1268 $clearTargeting = $this->cfg->cacheClearTargeting;
1269 if ($clearTargeting) {
1271 db::get(
'table', $tbl)->clearCache(
false);
1274 if (!$this->cfg->cacheEnabled)
1276 return $this->
getDb()->getCache()->delete(array(
1277 'callFrom'=>
'db_table-select',
1291 public function getRow(array $data = array(), $withAuto =
false, array $morePrm = array()) {
1292 $cols = array_flip($this->cols);
1293 $data = array_intersect_key($data,
$cols);
1295 foreach($this->fields as &
$f) {
1296 if ((!$f[
'auto'] || $withAuto) && !array_key_exists($f[
'name'], $data))
1297 $data[$f[
'name']] = $f[
'default'];
1300 $prm = array_merge($morePrm, array(
1301 'db'=>$this->
getDb(),
1304 if (array_key_exists($this->
getIdent(), $data) && $data[$this->
getIdent()])
1305 $prm[
'findId'] = $data[$this->
getIdent()];
1306 return db::get(
'row', $this, $prm);
static htmlOut($val, $key=false)
getLinkedTableRow($field, array $data=array())
dateAutoData(array &$data, $type)
getLinkedTableName($tablename)
select(array $prm=array())
static parseLinked(array &$data, array $linked)
getRelatedTableName($name, $add=true)
static initTab(array &$vars, array $init)
selectQuery(array $prm, &$tmpTables)
getRow(array $data=array(), $withAuto=false, array $morePrm=array())
clearCache($clearTargeting=null)
getI18nLabel($field=null)
findText($text, $filter=null)
static unI18nName($field)
static isI18nName($field)
static mergeCfg(array &$prm, array $cfg)
update(array $data, $where=null)
static get($type, $table, array $prm=array())
getField($field=null, $keyVal=null)
getWhere(array $prm=array())
getRelatedTableRow($name, array $data=array())