예제 #1
0
 private function create()
 {
     $this->write_magic_time('created_at');
     $this->write_magic_time('updated_at');
     $pk = $this->primary_key();
     $table = $this->table();
     $fields = $this->map_real_fields();
     $sql_fields = implode("`,`", array_keys($fields));
     $sql_values = implode(",", array_map(array($this, 'prepare_for_value'), $fields));
     $sql = "INSERT INTO `{$table}` (`{$sql_fields}`) VALUES ({$sql_values});";
     DbCommand::execute($sql);
     $this->{$pk} = DbCommand::insert_id();
     $this->_exists = true;
 }