Esempio n. 1
0
 /**
  * Compiles an insert string and runs the query.
  *
  * @param   string  table name
  * @param   array   array of key/value pairs to insert
  * @return  Database_Result  Query result
  */
 public function insert($table = '', $set = NULL)
 {
     if (!is_null($set)) {
         $this->setValue($set);
     }
     if ($this->_set == NULL) {
         throw new KoException('database.must_use_set');
     }
     if ($table == '') {
         if (!isset($this->_from[0])) {
             throw new KoException('database.must_use_table');
         }
         $table = $this->_from[0];
     }
     $sql = $this->_driver->insert($this->_config['table_prefix'] . $table, array_keys($this->_set), array_values($this->_set));
     $this->reset();
     return $this->query($sql);
 }