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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2008, 10:09 AM
mel mel is offline
Junior Member
 
Join Date: Feb 2008
Posts: 11
Question Where clause using in (value1, value2)

I'm new to ZF, and it's possible I've just overlooked what I need, but...

I want to do a query like:
SELECT * FROM table WHERE column IN (value1, value2, ...)

So far, I'm using Zend_Db_Adapter::query().

Thanks for any suggestions on how to do this - I feel like it shouldn't be that hard!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 10:18 AM
Member
 
Join Date: Feb 2008
Posts: 46
Default

$options = array('host'=> 'localhost',
'username'=> 'username',
'password'=> 'pwd',
'dbname'=> 'test'
);
$db = Zend_Db::factory('Pdo_Mysql', $options);

$result = $db->query("your query");

echo $result->fieldname;
or
echo $result['fieldname'];
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 10:43 AM
mel mel is offline
Junior Member
 
Join Date: Feb 2008
Posts: 11
Default

Thanks for that, but what I'm really looking for is how to use "in" specifically.

For some reason, query() doesn't seem to be returning any results, so I'm now using fetchAll().

So, the following returns all records for user 2:

$sql = 'SELECT * FROM table WHERE user_id in (?)';
$result = $db->fetchAll($sql, 2);

But I want all records for users 2, 3, and 4.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 05:43 AM
Member
 
Join Date: Feb 2008
Posts: 46
Question How to get Mysql Errors in ZF?

I want to print the mysql error in ZF. if anyone know this, plz send me.

-mugesh.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 06:46 PM
Senior Member
 
Join Date: Jan 2008
Location: chicago
Posts: 100
Default

turn on error reporting
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 04:56 AM.