->selectAdd() – Add selected columns


void $DB_DataObject->selectAdd ( string $condition )


Adds a selected columns. By default a select query will request all items (eg. SELECT * FROM table), to change this behavior you can first call selectAdd() without any arguments to clear the current request and then add the specific items you require.

You can also set up a default selection query by adding SelectAdd() method calls in the object constructor method (the one with the same name as the class)


  • resource $key - table column name


This function can not be called statically.


Using selectAdd()

= new DataObjects_Person;

while (
$person->fetch()) {
"{$person->id} {$person->name}<BR>";

$person = new DataObjects_Person;
$person->selectAdd("DATE_FORMAT(birthday,'%d %m %Y') as birthday_formated ");
$person->id 12;

"{$person->name} {$person->birthday_formated}<BR>";

Resulting SQL

SELECT id,name FROM person

SELECT *, DATE_FORMAT(birthday,'%d %m %Y') as birthday_formated  FROM person WHERE id=12
Free resources (Previous) Add WHERE statement (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:

Note by: madsliejensen
To prepend DISTINCT use:

$object->selectAdd('DISTINCT ' . $object->selectAdd());