I am still wondering why CodeIgniter just don't provide generic functions for model which can be generally usefull for creating reading update deleting joining and other manipulation of records to provide facility to the user and save time of the developer i have read about the Grocery CRUD but it is not that what i am looking for i have created two three function which you can call generic functions for retrieving and updating. Here the functions are.
returns multiple records
function get_records($table, $where=NULL)
{
if(!empty($where))
{
$this->db->where($where);
}
$query=$this->db->get($table);
if($query->num_rows>0)
{
return $query->result();
}
else
{
return array();
}
return single record
function get_record($table, $where=NULL)
{
if(!empty($where))
{
$this->db->where($where);
}
$query=$this->db->get($table);
if($query->num_rows>0)
{
return $query->row();
}
else
{
return 0;
}
}
Update()
general purpose function for updation
function update($table ,$where=NULL ,$data)
{
if(!empty($where))
{
$this->db->where($where);
}
$query=$this->db->update($table,$data);
if($query)
{
return $this->db->affected_rows();
}
}
delete()
//general purpose function for deletion
function delete($table , $where=NULL)
{
if(!empty($where))
{
$this->db->where($where);
}
if($this->db->delete($table))
{
return $this->db->affected_rows();
}
}
Here are my general function but There is alot more to do with CodeIgniter model because there are alot of functions which can be created as generic functions
My question is do any body have already derived this kind of stuff if yes provide me the link i have been looking for generic functions for CodeIgniter Model because if someone so it would be more time saving rather than writing one by our own
But in www do any body created generic functions for CodeIgniter model?
I am not very active in the CodeIgniter community anymore but the one that I used in the past is here
https://github.com/jamierumbelow/codeigniter-base-model
If you are looking to inject an ORM into CodeIgniter, perhaps you may want to look at this quick tutorial:
http://jamieonsoftware.com/post/90299647695/using-eloquent-orm-inside-codeigniter-with-added-query
CodeIgnite community has stopped updating the framework. I am not aware but i would suggest group of developers who can work on CI and make generic tools for CI. I am interested to be part of such groups