function insert() { if (isset($_POST)) { foreach ($_POST as $index => $valeur) { $donnees[$index] = $valeur; } } $data = new data(); $data->insert($donnees); }
public static function get_type($type) { if (array_key_exists($type, self::$types)) { return self::$types[$type]; } else { $t = data::fetch('*', 'logs_tipos', 'tipo = "' . $type . '"'); if (isset($t->id)) { self::$types[$type] = $t->id; return $t->id; } else { $id = data::insert('logs_tipos', 'tipo', '"' . $type . '"'); self::$types[$type] = $id; return $id; } } }
public function insert(array $fieldsValues) { $fields = array(); $values = array(); $this->fieldsValuesArray($fieldsValues, $fields, $values); return data::insert($this->tableName, $fields, $values); }
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 insert(array $valuesArray) { $valuesArray = data::escape($valuesArray); $fields = ''; $values = ''; foreach ($valuesArray as $k => $v) { if (array_key_exists($k, $this->fields)) { $fields .= '`' . $k . "`, "; $values .= "'" . $v . "', "; } else { die("<br /><b>ERROR:</b> field <i>\"{$k}\"</i> is not part of <i>\"{$this->name}\"</i><br />"); } } $fields = substr($fields, 0, -2); $values = substr($values, 0, -2); return data::insert($this->table, $fields, $values); }