D
D
Dmitry Evgrafovich2014-07-25 10:36:14
Kohana
Dmitry Evgrafovich, 2014-07-25 10:36:14

Why can't save query parameters in Kohana ORM?

I can't figure out why reset(FALSE) doesn't work in this code? An empty response is received. Of course, if find_all is called immediately on the same line where the parameters are set, then everything works fine.

if($prop == "shipping")
            {
                $clients = ORM::factory('client')
                  ->where('prop_retail', '=', 1)
                  ->order_by('id', 'DESC');
                $clients->reset(FALSE);

            }
            elseif($prop == "delivery")
            {
                $clients = ORM::factory('client')
                  ->where('prop_retail', '=', 2)
                  ->order_by('id', 'DESC');
                $clients->reset(FALSE);

            }
            elseif($prop == "office")
            {
                $clients = ORM::factory('client')
                  ->where('prop_retail', '=', 3)
                  ->order_by('id', 'DESC');
                $clients->reset(FALSE);
            }
            $clients->find_all();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Abrazhaev, 2014-07-31
@Tantacula

Example

$posts = ORM::factory("post") -> reset(false); /// Вот оно!
$posts = $posts -> where("published","=",1);
// Дальше накручиваем фильтров
if(......){
   $posts = $posts->where( ..........);
}
.........................
 
$count = $posts - >count_all();
 
// Теперь ничего не теряется
$posts = $posts -> limit(10)->offset(30)-> find_all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question