Пример #1
0
 public function insert($aValues)
 {
     $this->_query = "INSERT INTO `" . $this->_table . "` (`" . implode("`,`", array_keys($aValues)) . "`)\n             VALUES (:" . implode(",:", array_keys($aValues)) . ");";
     $this->bindParams($aValues);
     $this->prepare($this->_query);
     $this->execute();
     return DKY_DB::getLastInsertId();
 }
Пример #2
0
 /**
  * Insert a row into the specified table.
  *
  * @param string $tableName
  *            The name of the table to insert into.
  * @param array $aValues
  *            An associative array of columns to values to insert.
  * @return Returns the last insert ID on success, false on fail.
  */
 public static function insert($tableName, $aValues)
 {
     $sth = DKY_DB::query("INSERT INTO `" . $tableName . "` (`" . implode("`,`", array_keys($aValues)) . "`) \n             VALUES (:" . implode(",:", array_keys($aValues)) . ");");
     foreach ($aValues as $key => $value) {
         $sth->bind($key, $value);
     }
     if ($sth->execute()) {
         return DKY_DB::getLastInsertId();
     } else {
         return false;
     }
 }