Write a delete request for the next in the zend framework

I have a situation in my MySQL database table row repeating So I got this

DELETE from table1 USING table1, table1 as vtable WHERE (NOT table1.ID=vtable.ID) AND (table1.field_name=vtable.field_name) 

Where table1 is the table and vtable is the virtual table

How do I write that in the Zend Framework

+1
source share
2 answers

Zend_Db_Select supports the USING , but I think that it is not supported by the Zend_Db_Adapter delete() method.

A possible alternative would be to pass the SQL expression directly to the connection (if you use the pdo_mysql adapter, this will be a PDO object ):

$ db-> GetConnection () β†’ Exec ($ sqlExpression);

( IMPORTANT : make sure that you correctly specify all identifiers and values ​​in the SQL statement, Zend_Db_Adapter has extensive documentation about this).

+2
source

I'm not sure what you are trying to do, but here is how to use basic delete in Zend:

 $db->delete('table1', array('ID != ?' => $otherID, 'field_name = ?' => $otherFieldName)); 

Is this what you are looking for?

+1
source

Source: https://habr.com/ru/post/1383833/


All Articles