Delete Query

Delete Query:- It is used to delete record from the custom table.

Syntax:-

[php]
$write_connection = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$where = array($write_connection ->quoteInto(‘tableId =?’, table_id));
$write_connection->delete(‘tablename’,$where);

[/php]

Example:- Suppose, you have to delete records of the employee table which has employee’s 1.

[php]
$write_connection = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$where = array($write_connection ->quoteInto(‘tableId =?’, ‘1’));
$write_connection->delete(’employee’,$where);
[/php]