You are here

function DB_storage::setup in Flickr API 5

Method used to initialize a DB_storage object from the configured table.

Parameters

$keyval mixed the key[s] of the row to fetch (string or array):

Return value

int DB_OK on success, a DB error if not

1 call to DB_storage::setup()
DB_storage::insert in phpFlickr/PEAR/DB/storage.php
Create a new (empty) row in the configured table for this object.

File

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

Class

DB_storage
Provides an object interface to a table row

Code

function setup($keyval) {
  $whereclause = $this
    ->_makeWhere($keyval);
  $query = 'SELECT * FROM ' . $this->_table . ' WHERE ' . $whereclause;
  $sth = $this->_dbh
    ->query($query);
  if (DB::isError($sth)) {
    return $sth;
  }
  $row = $sth
    ->fetchRow(DB_FETCHMODE_ASSOC);
  if (DB::isError($row)) {
    return $row;
  }
  if (!$row) {
    return $this
      ->raiseError(null, DB_ERROR_NOT_FOUND, null, null, $query, null, true);
  }
  foreach ($row as $key => $value) {
    $this->_properties[$key] = true;
    $this->{$key} = $value;
  }
  return DB_OK;
}