⚠ 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

Taking where_in function() in codeigniter to GC



kenshicu
  • profile picture
  • Member

Posted 19 June 2013 - 19:35 PM

In the library grocery_crud.php in function protected function get_list() add:

if(!empty($this->in_where))
   foreach($this->in_where as $in_where):
	$this->basic_model->where($in_where[0].' in '.$in_where[1]);
   endforeach;

In class grocery_CRUD extends grocery_CRUD_States add:

protected $in_where 			= array();

also add in the same class, after function public function or_where(..), the following function:

public function in_where($key, $value = NULL, $escape = TRUE)
	{
		if ($value != '()') $this->in_where[] = array($key,$value,$escape);
	}

in the controller:

$crud->in_where('workers.id_workplace', $workplace_list);

where $workplace_list containing for example: (1, 15, 3, 8, 20)

is a list of id of workplaces, to get only the workers who are in the workplace specified in the list.

 

 

if anyone has a better idea, tell me :)