Login
Donate to Zikula
Wiki : DeleteOperations
Documentation Home :: Categories :: Page Index :: recent changes :: Search :: Help :: Log in
last edit 2006-06-21 18:45:03 by markwest fixed wiki words

Additions:
deleteObject uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables and make object an empty array.
This function allows us to create a custom where clause. Remember to use pnTables to get the correct column names:
Deletions:
deleteObject? uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables?).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables? and make object an empty array.
This function allows us to create a custom where clause. Remember to use pnTables? to get the correct column names:
edited 2006-06-05 15:52:52 by Chestnut small display fix

Additions:
Deletions:
edited 2006-05-29 10:25:22 by Chestnut Tidy fix...

Additions:
deleteObject? ($object, $tablename, $where='', $idcolumn='')
Deletions:
deleteObject? ($object, $tablename, $where=, $idcolumn='id')
Oldest known version of this page was edited on 2006-05-04 13:10:43 by markwest [ moved from temp wiki ]
deleteObjectByID? ($tablename, $id, $idcolumn='id')
This function will delete one row in the database by the id field. Two examples:
We can also cheat a little with something like this:
This would delete multiple rows since the ID field specified is no unique. This provides a nice little shortcut.
deleteObject? ($object, $tablename, $where=, $idcolumn='id')
deleteObject? uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables?).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables? and make object an empty array.
deleteWhere? ($tablename, $where)
This function allows us to create a custom where clause. Remember to use pnTables? to get the correct column names:
If the $where clause blank it will effectively empty the table.
Previous | Top | Next
CategoryDeveloperDocs
Additions:
deleteObject uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables and make object an empty array.
This function allows us to create a custom where clause. Remember to use pnTables to get the correct column names:
Deletions:
deleteObject? uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables?).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables? and make object an empty array.
This function allows us to create a custom where clause. Remember to use pnTables? to get the correct column names:
edited 2006-06-05 15:52:52 by Chestnut small display fix
Additions:
deleteObjectByID
deleteObjectByID ($tablename, $id, $idcolumn='id')deleteObject
deleteObject ($object, $tablename, $where='', $idcolumn='')deleteWhere
deleteWhere ($tablename, $where)Deletions:
deleteObjectByID?
deleteObjectByID? ($tablename, $id, $idcolumn='id')deleteObject?
deleteObject? ($object, $tablename, $where='', $idcolumn='')deleteWhere?
deleteWhere? ($tablename, $where)edited 2006-05-29 10:25:22 by Chestnut Tidy fix...
Additions:
deleteObject? ($object, $tablename, $where='', $idcolumn='')
Deletions:
deleteObject? ($object, $tablename, $where=, $idcolumn='id')
Oldest known version of this page was edited on 2006-05-04 13:10:43 by markwest [ moved from temp wiki ]
Delete Operations
deleteObjectByID?
/**
* Delete an object by its ID.
*
* @param tablename The tablename key for the PNTables structure
* @param id The ID of the object to delete
* @param idcolumn The column which contains the ID field (optional) (default='id')
*
* @return The result from the delete operation
*/
function deleteObjectByID ($tablename, $id, $idcolumn='id')
* Delete an object by its ID.
*
* @param tablename The tablename key for the PNTables structure
* @param id The ID of the object to delete
* @param idcolumn The column which contains the ID field (optional) (default='id')
*
* @return The result from the delete operation
*/
function deleteObjectByID ($tablename, $id, $idcolumn='id')
deleteObjectByID? ($tablename, $id, $idcolumn='id')
This function will delete one row in the database by the id field. Two examples:
DBUtil::deleteObjectById ('mytable', 4);
DBUtil::deleteObjectById ('customers', $customerid, 'cust_id');
DBUtil::deleteObjectById ('customers', $customerid, 'cust_id');
We can also cheat a little with something like this:
DBUtil::deleteObjectById ('customers', 'USA', 'country');
This would delete multiple rows since the ID field specified is no unique. This provides a nice little shortcut.
deleteObject?
/**
* Generate and execute a delete SQL statement for the given object
*
* @param object The object we wish to update
* @param tablename The tablename key for the PNTables structure
* @param where The where clause to use (optional) (default='')
* @param idcolumn The column which contains the ID field (optional) (default='id')
*
* @return The result from the delete operation
*/
function deleteObject ($object, $tablename, $where='', $idcolumn='id')
* Generate and execute a delete SQL statement for the given object
*
* @param object The object we wish to update
* @param tablename The tablename key for the PNTables structure
* @param where The where clause to use (optional) (default='')
* @param idcolumn The column which contains the ID field (optional) (default='id')
*
* @return The result from the delete operation
*/
function deleteObject ($object, $tablename, $where='', $idcolumn='id')
deleteObject? ($object, $tablename, $where=, $idcolumn='id')
deleteObject? uses the $object to build a where clause. This is useful because one can simple parse an object directly from an input form for example to be deleted. No need to build any where clauses (and have to use pnTables?).
NOTE You cannot specify an object *and* and where clause together, one must be blank. To use a where clause you should use pnTables? and make object an empty array.
// using an object to build the where clause
DBUtil::deleteObject ($obj, 'customers');
// building a where clause
$pntables = pnDBGetTables();
$column = $pntables['customers_column'];
$where = "WHERE $column[name]='Fred' AND $column[country]='Netherlands'";
DBUtil::deleteObject (array(), 'customers', $where);
DBUtil::deleteObject ($obj, 'customers');
// building a where clause
$pntables = pnDBGetTables();
$column = $pntables['customers_column'];
$where = "WHERE $column[name]='Fred' AND $column[country]='Netherlands'";
DBUtil::deleteObject (array(), 'customers', $where);
deleteWhere?
/**
* Delete (an) object(s) via a where clause
*
* @param tablename The tablename key for the PNTables structure
* @param where The where-clause to use
*
* @return The result from the delete operation
*/
function deleteWhere ($tablename, $where)
* Delete (an) object(s) via a where clause
*
* @param tablename The tablename key for the PNTables structure
* @param where The where-clause to use
*
* @return The result from the delete operation
*/
function deleteWhere ($tablename, $where)
deleteWhere? ($tablename, $where)
This function allows us to create a custom where clause. Remember to use pnTables? to get the correct column names:
$pntables = pnDBGetTables();
$column = $pntables['customers_column'];
$where = "WHERE $column[name]='Fred' AND $column[country]='Netherlands'";
DBUtil::deleteWhere ('customers', $where);
$column = $pntables['customers_column'];
$where = "WHERE $column[name]='Fred' AND $column[country]='Netherlands'";
DBUtil::deleteWhere ('customers', $where);
If the $where clause blank it will effectively empty the table.
Previous | Top | Next
CategoryDeveloperDocs

latest author:
Owner: