->delete() -- Delete items from table
Descripción
Deletes data from the database, either using primary key or based on a
whereAdd() method call.
By default the delete will base it's query on the set variables,
however if you wish to use the
whereAdd()
method you should set the $useWhere parameter to DB_DATAOBJECT_WHEREADD_ONLY.
Valor devuelto
int number of rows affected or FALSE on failure
Nota
Esta función no puede ser llamada
estáticamente.
Ejemplo
Ejemplo 35-1. Simple Delete
<?php
$person = new DataObjects_Person;
$person->get(12);
$person->delete();
$person = new DataObjects_Person;
$person->whereAdd('age < 21');
$person->delete(DB_DATAOBJECT_WHEREADD_ONLY);
?>
|
|
Ejemplo 35-2. Resulting SQL
<?php
SELECT * FROM person WHERE id=12
DELETE FROM person WHERE id=12 AND name='test' AND age=21
DELETE FROM person WHERE age < 21
?>
|
|