find
  • phalcon
  • 2017-03-04 56 views 0 likes 
    0
    數據

    有人可以解釋我如何兩個爾康表中搜索數據:如何搜索有兩種爾康表

    我有這個疑問:

    $Q = $this->request->getPost("data"); 
    $phql = 'SELECT b.idbank,b.name,m.description,m.date 
         FROM bank b 
         inner join movement m on b.idbank=m.idbank 
         WHERE b.estado = 1 and b.name like "%'.$Q.'%" or m.description like "%'.$Q.'%" 
         Order by b.idbank desc 
         '; 
    
    $bank = $this->modelsManager->executeQuery($phql); 
    

    會有一些方法來做到這一點這樣:

    $Q = $this->request->getPost("data"); 
    $bank = Bank::find([ 
        "name like '%:dato:%'", 
        "bind" => [ 
         "dato" => $Q 
        ] 
    ]); 
    
    $mov = $bank->getmovement([ 
        "description like '%:dato:%'", 
        "bind" => [ 
         "dato" => $Q 
        ] 
    ]); 
    $bank = $mov->bank; 
    

    我其實不知道該怎麼做。

    我所做的並不是爲我工作。

    回答

    0

    您需要將百分比從條件佔位符移動到綁定參數。第一個查詢返工:

    $bank = Bank::find([ 
        "name like :dato:", 
        "bind" => [ 
         "dato" => '%'. $Q .'%' 
        ] 
    ]); 
    

    更多的例子在the Documentation

    相關問題