Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



36.5k
edited Oct '14

Hi all, I solve problem above

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


84.5k
Accepted
answer

The right way is removing the extra '=':

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


36.5k

thank phalcon