You are here

function DB_storage::insert in Flickr API 5

Create a new (empty) row in the configured table for this object.

File

phpFlickr/PEAR/DB/storage.php, line 196

Class

DB_storage
Provides an object interface to a table row

Code

function insert($newpk) {
  if (is_array($this->_keycolumn)) {
    $primarykey = $this->_keycolumn;
  }
  else {
    $primarykey = array(
      $this->_keycolumn,
    );
  }
  settype($newpk, "array");
  for ($i = 0; $i < sizeof($primarykey); $i++) {
    $pkvals[] = $this->_dbh
      ->quote($newpk[$i]);
  }
  $sth = $this->_dbh
    ->query("INSERT INTO {$this->_table} (" . implode(",", $primarykey) . ") VALUES(" . implode(",", $pkvals) . ")");
  if (DB::isError($sth)) {
    return $sth;
  }
  if (sizeof($newpk) == 1) {
    $newpk = $newpk[0];
  }
  $this
    ->setup($newpk);
}