Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 16474 программиста и 1770 роботов. Сейчас ищут 1323 программиста ...

->selectAdd()

Вернуться к: DB_DataObject

->selectAdd()

->selectAdd() – Add selected columns

Synopsis

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)

Parameter

  • resource $key - table column name

Note

This function can not be called statically.

Example

Using selectAdd()

<?php
$person 
= new DataObjects_Person;
$person->selectAdd();
$person->selectAdd('id,name');

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


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

echo 
"{$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


Вернуться к: DB_DataObject

© 2025 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware