We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

query conditions

Hi all My problem as:

$queryTerms = '%'.preg_replace('/[ \t]+/', '%', $q).'%'; // %08%
$Hososinhvien = Hososinhvien::find(array(
        "conditions" => "MaSV LIKE = ?1",
        "bind"       => array(1 => $queryTerms)
  ));

after run mycode above display Syntax error, unexpected token EQUALS, near to ' ?1', when parsing: SELECT [Eduapps\Backend\Models\Hososinhvien].* FROM [Eduapps\Backend\Models\Hososinhvien] WHERE MaSV LIKE = ?1 (110) help



58.4k
edited Oct '14

Hi all, I solve problem above

    $queryTerms = '%'.preg_replace('/[ \t]+/', '%', $q).'%'; // %08%
    $Hososinhvien = Hososinhvien::find(array(
    "conditions" => "MaSV LIKE  '$queryTerms'"'
    ));


98.9k
Accepted
answer

The right way is removing the extra '=':

$Hososinhvien = Hososinhvien::find(array(
"conditions" => "MaSV LIKE ?1",
"bind" => array(1 => $queryTerms)
));


58.4k

thank phalcon