2016-03-05 54 views
1

我有这样的查询在CakePHP程序动态变量查询

  // Check for txn_id 
      $txns = $this->$transaction_class->find('count', array(
       'conditions' => array(
        $transaction_class.'.txn' => $txnId 
       ) 
      )); 

正如你看到的,我的变量transaction_class是一个动态变量。形成某种原因,这是行不通的。我甚至试图把变量里面{},如:

  // Check for txn_id 
      $txns = $this->{$transaction_class}->find('count', array(
       'conditions' => array(
        $transaction_class.'.txn' => $txnId 
       ) 
      )); 

但是,这也不能工作。有人知道我该如何做这项工作吗?

感谢

回答

0

首先检查你的模型导入这个网页或没有或增加$使用阵列。

+0

谢谢。我忘了加载我的模型 – user765368