Closed peixespnsc closed 4 years ago
I've found the solution, it's like so:
//find one user by two conditions
$user = $model->find("first_name = :name AND last_name = :last", "name=Robson&last=Leite")->fetch();
echo $user->first_name . " " . $user->first_last;
But now I have a problem with IN, the "find" only returns the first value
//find users by two conditions
$user = $model->find("first_name = :name AND id IN (:id)", "name=Robson&id=1,2,3,4")->fetch(true);
var_dump($user);
Boa tarde galera, vejam meu pull request que resolvo todos estes problemas.
https://github.com/rodineiti/datalayer/blob/develop/README.md
Rodinei, estou tomando erro Undefined method 'where'. ao tentar usar a forma where da nova consulta implementada.
$funcionario = new Funcionario(); $listFunc = $funcionario->where("id", ">", 1)->find()->fetch(true);
Rodinei, estou tomando erro Método indefinido 'where'. ao tentar usar uma forma em que a nova consulta é implementada.
$funcionario = new Funcionario(); $listFunc = $funcionario->where("id", ">", 1)->find()->fetch(true);
Bom dia Thiago, obrigado por utilizar. Segue nova forma de utilizar com o método Where:
<?php
$funcionario = new Funcionario();
$listFunc = $funcionario->where("id", ">", 1)->get(true)
No método get(), eu já chamo o find e o fetch, desta forma, as condições utilizadas são a da where. Ainda assim, com os novos recursos que fiz, mantive a retro-compatibilidade dos métodos atuais como find. Dá uma olhada nos arquivos de exemplo: https://github.com/rodineiti/datalayer/tree/develop/example
Lá eu mostro como utilizar. Mas pode contar comigo se precisar de ajuda.
$users = $model->find("age > :age", "age=16")->fetch();
$user = $model->find("first_name = :name AND last_name = :last", "name=Robson&last=Leite")->fetch();
Is there AND clause implemented? If so, how to proced? Thanks!