Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-06-2008, 10:06 AM
tru tru is offline
Junior Member
 
Join Date: Jul 2008
Posts: 10
Default delte(), update() and "where" variable

Hi,
I've got a script which edits and deletes data in database. To select row for edit/del, I want to use $id variable.
To perform a sql qeury "SELECT" I use following code
PHP Code:
$id $this->getRequest()->getParam('id');
(...)
$db->fetchAll('SELECT * FROM table WHERE id = ?'$id
Could you please tell me how can I insert $id variable into update() and delete() function? Using those functions I'd like to perform query like this
Code:
DELETE FROM table WHERE id = $id
I'd like to add that '$id = ?', $id doesn't work.

Regards,
Tru
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-11-2008, 03:35 AM
Member
 
Join Date: Jul 2008
Posts: 60
Default

The delete and update functions both take a standard where clause as the final argument, but don't do variable insertion. The adapter has a separate quoteInto() function that can handle that though.

Your example delete would look like
Code:
$adapter->delete('table', $adapter->quoteInto('id = ?', $id));
__________________
Brenton Alker
Brisbane, Australia

http://blog.tekerson.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:39 AM.