I have two tables: cities and coutries.
CREATE TABLE IF NOT EXISTS `cities` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`country_id` int(10) not null,
`city` varchar(255) NOT NULL,
`active` int(1) not null,
PRIMARY KEY (`id`),
FOREIGN KEY (country_id) REFERENCES countries (id)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`country` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
My controller is:
public function cities() {
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('cities');
$crud->where('active', 1);
$crud->set_relation('country_id', 'countries', 'country');
$output = $crud->render();
$this->_example_output($output);
}
public function countries() {
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('countries');
$output = $crud->render();
$this->_example_output($output);
}
If i try to search for the word "Tor" i would expect to see 1 rows but i will get all the rows! why?
my select is:
SELECT `cities`.*, j93bfec8a.country AS s93bfec8a
FROM `cities`
LEFT JOIN `countries` as `j93bfec8a` ON `j93bfec8a`.`id` = `cities`.`country_id`
WHERE `active` =0
OR `j93bfec8a`.`country` LIKE '%Tor%' ESCAPE '!'
OR `city` LIKE '%Tor%' ESCAPE '!'
OR `active` LIKE '%Tor%' ESCAPE '!'
HAVING `active` =0
LIMIT 5
Someone to help me please!
I use grocerycrud v1.5.2 and codeigniter v3.0.3.