私はこの機能を持っています
protected function insert($data){
$data['datecreated'] = date('Y-m-d h:i:s');
echo "array_keys(data) = ".$data['datecreated'];
var_dump($data);
echo array_keys($data);
$sql = "INSERT INTO {$this->table_name} (". array_keys($data).")";
$sql.= " VALUES ('";
$sql.=implode("','", $data);
$sql.=")";
$this->execute($sql);
$this->last_id = mysql_insert_id();
}
私が読んだとき、array_keys($data)
それは私がこのようにそれを呼ぶキーではなく「配列」を返します$this->insert(array());
なぜそれですか?編集:これは出力です
array_keys(data) = 2012-05-18 04:44:46array(2) { [0]=> array(0) { } ["datecreated"]=> string(19) "2012-05-18 04:44:46" } Array
Notice: Array to string conversion in /Applications/MAMP/htdocs/Tamara/model/dbTable.php on line 105
INSERT INTO account (Array) VALUES ('Array','2012-05-18 04:44:46)You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2012-05-18 04:44:46)' at line 1