Return to Snippet

Revision: 57976
at June 19, 2012 00:42 by drock


Updated Code
$criteria = new CDbCriteria();
$criteria->condition = 'start=:startID AND end=:endID';
$criteria->params = array(':startID'=>$activeProfileID,':endID'=>$pageID);
$criteria->addInCondition('status',array(6,7));		
$results = GraphEdge::model()->findAll($criteria);

//OR

$theEdge = new GraphEdge();
$results = $theEdge->findAllByAttributes(array('start'=>$activeProfileID,'end'=>$pageID,'status'=>array(6,7)));

Revision: 57975
at June 19, 2012 00:40 by drock


Updated Code
$criteria = new CDbCriteria();
$criteria->condition = 'start=:startID AND end=:endID';
$criteria->params = array(':startID'=>$activeProfileID,':endID'=>$pageID);
$criteria->addInCondition('status',array(6,7));		
$currentVerifies = GraphEdge::model()->findAll($criteria);

//OR
$theEdge = new GraphEdge();
$currentVerifies = $theEdge->findAllByAttributes(array('start'=>$activeProfileID,'end'=>$pageID,'status'=>array(6,7)));

Revision: 57974
at June 19, 2012 00:13 by drock


Initial Code
$criteria = new CDbCriteria();
$criteria->condition = 'start=:startID AND end=:endID';
$criteria->params = array(':startID'=>$activeProfileID,':endID'=>$pageID);
$criteria->addInCondition('status',array(6,7));		
$currentVerifies = GraphEdge::model()->findAll($criteria);

Initial URL

                                

Initial Description
When working with your model's search function or just grabbing some data with findAll, you can't add an IN condition to your condition clause. Fail:
<code>$criteria->condition = 'start=:startID AND end=:endID AND status IN (1,2,3)';</code> 

Instead, use addInCondition:

Initial Title
Yii: Using MySQL\'s IN condition with Active Record

Initial Tags

                                

Initial Language
PHP