public function createComponentFromTable($tableName) { $return = NULL; $count = data::select('COUNT(*) AS TOTAL', $tableName, NULL, NULL, 1) or $return = false; $count = $count->fetch(); if ($count['TOTAL'] == 0) { data::insert($tableName, array('id'), array(1)); } //TODO: Fix ID for primary key. $result = data::select('*', $tableName, NULL, NULL, 1) or $return = false; if ($return === false) { return false; } $total = $result->columnCount(); $fields = array(); for ($x = 0; $x < $total; $x++) { $meta = $result->getColumnMeta($x); //var_export($meta); echo "------------------<br />\n"; $type = in_array('primary_key', $meta['flags']) ? 'id' : $this->getTypeFromMeta($meta, $tableName, $meta['name']); array_push($fields, new Field($meta['name'], $type)); } if ($count['TOTAL'] == 0) { data::delete($tableName); } $newComponent = new cmp_interface($tableName, new fieldSet($fields)); $newComponent->name = $tableName; return $newComponent; }
public function delete($id = NULL) { if ($id !== NULL) { $this->filter("id = " . data::escapeString($id)); data::delete($this->tableName, $this->where, $this->order, $this->limit); } else { ###LO DE MA } }
public function delete($id = NULL) { if ($this->where != NULL or $this->order != NULL or $this->limit != NULL) { $return = data::delete($this->table, $this->where, $this->order, $this->limit); $this->clearQuery(); return $return; } else { if (id != NULL) { return data::delete($this->table, $id); } else { return false; } } }