⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

where and filter options does not works using flexigrid



Wilder Batista González

Wilder Batista González
  • profile picture
  • Member

Posted 23 April 2014 - 17:04 PM

Hello to everybody:

I have used Grocery CRUD in my Apps and have noted that when I use where option in my functions the filter options doesn't works, using flexigrid theme too. The following example is a simple modification in your example.php controller in the customers_management funtion, note that I add the line $crud->where("country", "USA"); to ilustrate the bug:

 

public function customers_management()
    {
            $crud = new grocery_CRUD();

            $crud->set_table('customers');
            $crud->where("country", "USA");
            $crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit');
            $crud->display_as('salesRepEmployeeNumber','from Employeer')
                 ->display_as('customerName','Name')
                 ->display_as('contactLastName','Last Name');
            $crud->set_subject('Customer');
            $crud->set_relation('salesRepEmployeeNumber','employees','lastName');

            $output = $crud->render();

            $this->_example_output($output);
    }

 

Everything works except when I want to filter for any column a database error is triggered:

 

A Database Error Occurred
Error Number: 1054 Unknown column 'country' in 'having clause

 

'SELECT COUNT(*) AS `numrows`
FROM (`customers`)
WHERE `country` =  'USA'
AND  `customerName`  LIKE '%muscle%'
OR  `contactLastName`  LIKE '%muscle%'
OR  `phone`  LIKE '%muscle%'
OR  `city`  LIKE '%muscle%'
OR  `country`  LIKE '%muscle%'
OR  `salesRepEmployeeNumber`  LIKE '%muscle%'
OR  `creditLimit`  LIKE '%muscle%'
HAVING `country` =  'USA'

 

Filename: D:\USBWebserver v8.5\root\Grocery_CRUD\system\database\DB_driver.php

Line Number: 330

 

Advanced thanks for your help