|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
INSERT IF NOT EXISTS with Zend_Db_Table_RowIs it possible to INSERT IF NOT EXITSTS using a
Zend_Db_Table_Row or should I generate the query by hand? I searched the docs but I couldn’t find anything. Kevin Hallmark |
|
|
RE: INSERT IF NOT EXISTS with Zend_Db_Table_RowFor future reference for anyone who has my
problem: http://www.nabble.com/REPLACE-queries-on-Zend_Db-td15617859.html Basically, as far as I can tell, Zend_Db
doesn’t support ‘INSERT IGNORE’ or ‘ON DUPLICATE KEY
UPDATE’ syntax using Zend_Db_Table and Zend_Db_Table_Row. You’re only choice is to use the
query method of the Zend_Db_Adapter class of your choice and manually creating
the query. Kevin Hallmark From: Kevin Hallmark
[mailto:Kevin.Hallmark@...] Is it possible to INSERT IF NOT EXITSTS using a
Zend_Db_Table_Row or should I generate the query by hand? I searched the docs but I couldn’t find anything. Kevin Hallmark |
|
|
Re: INSERT IF NOT EXISTS with Zend_Db_Table_RowI handle this at the level of the model using an exists($keys : Array)
method on a generic DataObject. A dataobject is like an active record. That way you can check myDataObject->exists() to find out what you have to do. Regards, Bart McLeod Kevin Hallmark schreef: > > For future reference for anyone who has my problem: > > http://www.nabble.com/REPLACE-queries-on-Zend_Db-td15617859.html > > Basically, as far as I can tell, Zend_Db doesn’t support ‘INSERT > IGNORE’ or ‘ON DUPLICATE KEY UPDATE’ syntax using Zend_Db_Table and > Zend_Db_Table_Row. > > You’re only choice is to use the query method of the Zend_Db_Adapter > class of your choice and manually creating the query. > > Kevin Hallmark > > ------------------------------------------------------------------------ > > *From:* Kevin Hallmark [mailto:Kevin.Hallmark@...] > *Sent:* Tuesday, May 13, 2008 9:53 AM > *To:* fw-general@... > *Subject:* [fw-general] INSERT IF NOT EXISTS with Zend_Db_Table_Row > > Is it possible to INSERT IF NOT EXITSTS using a Zend_Db_Table_Row or > should I generate the query by hand? > > I searched the docs but I couldn’t find anything. > > Kevin Hallmark > |
|
|
RE: INSERT IF NOT EXISTS with Zend_Db_Table_RowI actually ended up solving my problem at the SQL level.
I was tracking statistics. I'm tracking each and every hit of 6 different types to an incredibly simple table. I also needed to track the daily aggregate of hit types, per 'page' per day ('page' is the data I'm tracking for). For ease of generating reports, I wanted all the different hit types in one row. (Generating the report I needed would have required 6 queries per row for 'page' listings sometimes totaling hundreds of 'pages' so 6*x where x is the number of 'pages' in the list) The reason I needed 'ignore' was so I could insert the 'page'/date keyed row no matter what (making sure it's there). Then increment the appropriate tally. It turns out the best solution was an AFTER INSERT trigger. I wrote a little stored procedure to INSERT IGNORE and then UPDATE the appropriate hit type. Then I just call that SP from the trigger. Kevin Hallmark PHP Developer Bonnier Corporation -----Original Message----- From: Bart McLeod [mailto:mcleod@...] Sent: Thursday, May 15, 2008 4:01 AM To: Kevin Hallmark Cc: fw-general@... Subject: Re: [fw-general] INSERT IF NOT EXISTS with Zend_Db_Table_Row I handle this at the level of the model using an exists($keys : Array) method on a generic DataObject. A dataobject is like an active record. That way you can check myDataObject->exists() to find out what you have to do. Regards, Bart McLeod Kevin Hallmark schreef: > > For future reference for anyone who has my problem: > > http://www.nabble.com/REPLACE-queries-on-Zend_Db-td15617859.html > > Basically, as far as I can tell, Zend_Db doesn't support 'INSERT > IGNORE' or 'ON DUPLICATE KEY UPDATE' syntax using Zend_Db_Table and > Zend_Db_Table_Row. > > You're only choice is to use the query method of the Zend_Db_Adapter > class of your choice and manually creating the query. > > Kevin Hallmark > > > > *From:* Kevin Hallmark [mailto:Kevin.Hallmark@...] > *Sent:* Tuesday, May 13, 2008 9:53 AM > *To:* fw-general@... > *Subject:* [fw-general] INSERT IF NOT EXISTS with Zend_Db_Table_Row > > Is it possible to INSERT IF NOT EXITSTS using a Zend_Db_Table_Row or > should I generate the query by hand? > > I searched the docs but I couldn't find anything. > > Kevin Hallmark > |
| Free Forum Powered by Nabble | Forum Help |