|
with Zend_Db(_Table) how can i do a mysql insert...on duplicate key update.
for those how dunno what that is ... http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html basically it means insert the row if it does not violate unique or primary keys else just the row. |
|
You can use for instance
function mySave(...) { return $re$yourTableInstance->getAdapter()->query('INSERT INTO ... ON DUPLICATE KEY UPDATE ...;')->rowCount(); } This behaves the same like insert() or update() of Zend_Db_Adapter_Abstract do. Cheers Patrick -----Ursprüngliche Nachricht----- Von: iceangel89 [mailto:[hidden email]] Gesendet: Montag, 4. Mai 2009 05:49 An: [hidden email] Betreff: [fw-db] INSERT ... ON DUPLICATE KEY UPDATE with Zend_Db(_Table) how can i do a mysql insert...on duplicate key update. for those how dunno what that is ... http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html basically it means insert the row if it does not violate unique or primary keys else just the row. -- View this message in context: http://www.nabble.com/INSERT-...-ON-DUPLICATE-KEY-UPDATE-tp23362664p23362664.html Sent from the Zend DB mailing list archive at Nabble.com. |
|
hmm, actually whats the benefit of using Zend_DB functions like select()->where ... ?
if i use query($sql) directly any downsides? maybe becos i am using a MySQL specific function, i cannot change db? is Zend_Db adapters and its functions so that one can change db easily? like MySQL to MSSQL?
|
|
IMO the select()->where etc. functions allow for a uniformed way of accessing your data source. Later on if you change the data source your code will not require any changes. However creating queries using Zend_Db_Select will always be slower than issuing the SQL statement directly. This is due to the object layer that has to be instantiated and executed.
Using the adapter with SQL queries directly is a perfectly good solution if that is what you want to do. I hope this helps. Nikolaos Dimopoulos
On Mon, May 4, 2009 at 21:56, iceangel89 <[hidden email]> wrote:
-- The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited. |
| Powered by Nabble | Edit this page |
