->get() – Simple Get (Select) request


int $DB_DataObject->get ( mixed Key or Value , mixed value )


Get a result using key, value. Returns Number of rows located (usually 1) for success, and puts all the table columns into this classes variables. If only one parameter is used, it is assumed that first parameter is a value and get() will use the primary key.


  • mixed $key or $value - column (or value if only one parameter)

  • mixed $value - value

Return value

int - Number of rows


Possible PEAR_Error values
Error code Error message Meaning Solution
DB_DATAOBJECT_ERROR_INVALIDCONFIG "No Keys available for $table"    
DB_DATAOBJECT_ERROR_INVALIDARGS "No Value specified for get"    


This function can not be called statically.

You should avoid calling get on the same object instance twice, as this will result in unexpected results.


Simple fetch of data based on Primary Key

= new DataObjects_Person;

Resulting SQL

SELECT * FROM person WHERE id=12

Simple fetch of data based on Key and Value

= new DataObjects_Person;

Resulting SQL

SELECT * FROM person WHERE email='test@example.com'

Results of example code

(DataObjects_Person) =>
N] => 1
[id] => 12
[group] => 5
[has_glasses] => 1
[name] => 'fred blogs'
[password] => '**testing'
[email] => 'test@example.com'
Autoload and instantate class based on table name. (Previous) Simple Get (Select) request, abbreviated and Autoload. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.