我有办公室部门之间的发票跟踪表。一旦我注册了发票,就会在表格中插入一个交易。我转发到物流办公室并插入了其他交易。在表中我有currentLocationId,nextlocationId,timein,timeout,action。 当我转发发票时,我不更新以前的发票登记记录,但我需要一旦我转发发票它就会退出队列。请记住,注册的初始事务是完整的,未更新的,如何在YII模型中过滤以仅获取已注册但尚未转发的记录?
以下是我的模特搜索。
public function showPending($id)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('invoices');
$criteria->together = true;
$criteria->compare('InvoiceTrackingID',$this->InvoiceTrackingID);
$criteria->compare('invoices.TrackingCode',$this->TrackingCode);
$criteria->compare('TimeInStamp',$this->TimeInStamp,true);
$criteria->compare('TimeOutStamp',$this->TimeOutStamp,true);
$criteria->compare('Comments',$this->Comments,true);
$criteria->compare('CurrentUnitLocationID',$this->CurrentUnitLocationID = $id); // see if the invoice is in your unit location
$criteria->compare('UserID',$this->UserID);
$criteria->compare('TrackingActionID',$this->TrackingActionID = 2); // fetch only invoices whose action was to forward to display
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
答案 0 :(得分:1)
首先,我需要查看您的表格,但无论如何您需要为条件添加条件 并将是这样的:
$criteria->addCondition(" your condition here ");
你也可以使用这样的复杂条件: 例如
$criteria->addCondition(" ticket_id not in (select ticket_id from table where coulmn=$section_id ) ");
*注意:在第一行添加条件语句,如:
public function showPending($id)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->addCondition(" your condition here ");
$criteria->with = array('invoices');
$criteria->together = true;
$criteria->compare('InvoiceTrackingID',$this->InvoiceTrackingID);
$criteria->compare('invoices.TrackingCode',$this->TrackingCode);
$criteria->compare('TimeInStamp',$this->TimeInStamp,true);
$criteria->compare('TimeOutStamp',$this->TimeOutStamp,true);
$criteria->compare('Comments',$this->Comments,true);
$criteria->compare('CurrentUnitLocationID',$this->CurrentUnitLocationID = $id); // see if the invoice is in your unit location
$criteria->compare('UserID',$this->UserID);
$criteria->compare('TrackingActionID',$this->TrackingActionID = 2); // fetch only invoices whose action was to forward to display
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}