Search code examples
codeigniterpyrocms

Is it possible to use a PyroCMS get_many_by with a LIKE?


$base_where = $this->input->post('f_OrderNumber') ? $base_where + array('OrderNumber' => '*' . $this->input->post('f_OrderNumber') . '*') : $base_where;

$orders = $this->orders_m->get_many_by($base_where);

Except I want the OrderNumber to be LIKE the POST


Solution

  • If your "orders_m" model is extending from MY_Model (which it probably is), you can use all the standard Codeigniter Active Record functions.

    if( $this->input->post('f_OrderNumber') )
    {
      $this->orders_m->like('OrderNumber', $this->input->post('f_OrderNumber'));
    }
    
    $orders = $this->orders_m->get_all(); // if you want everything OR
    $orders = $this->orders_m->get_many_by('field', 'value'); // if you have other parameters