if i try to load a result with Kohana ORM, the query is correct, but the result is empty. If i copy the Query and use it in phpmyadmin, i receive 2 rows.
This is the Kohana Code (ORM)
// DB work
$ftps = ORM::factory('ftp');
// if we activate many (we load only ready)
if ($this->request->param('mode') == 'activate') {
$ftps->where('ready', '=', '1');
// if we activate many (we load only ready)
} elseif ($this->request->param('mode') == 'not_ready') {
$ftps->where('ready', '=', '0');
}
// DB work
$ftps->and_where('activated', '=', '0')
->order_by('lastcheck', 'ASC')
->limit(intval($post['number']))
->find_all();
This is the SQL Query (Debug)
SELECT `ftp`.* FROM `ftps` AS `ftp` WHERE `activated` = '0' ORDER BY `lastcheck` ASC LIMIT 100 (1)
Why is Kohana not able to load the same results like phpmyadmin does? It’s the same query. I don’t find a solution.
Thank you for your help
This is a problem I used to encounter a lot when I was using Kohana. There is a simple but not-that-intuitive explanation to your problem. If you are simply doing…
and then try to use
$ftpas your results set, that won’t work, because thefind_all()function only returns the results set, and the$ftpsquery object is being reset. Instead, you need to do…and then
$ftpswill contain the results set.Hope that helps!