Welcome Guest, Not a member yet? Register   Sign In
Can't acccess personnal library
#6

(07-23-2016, 01:39 AM)Wouter60 Wrote: Usually, collecting data from your database is done by a Model, not a Library.
In a model, you can use the $this->db object without instantiating the super-object.

One more tip about your method. You are looping through a result_array(), but it seems that you expect the result to be 1 record.
In that case you can return this record like this:

PHP Code:
$query $this->CI->db->get_where('cms', array('page_name' => $pageName), 1);
return 
$query->row_array(); 

Hello and thank you wouter for your help.
I don't really know how to use the personal librairies; but if i understand, i had to call a specific model in the library as we use to do in controllers ?

If i use load->model in the library i have to instanciate CI or not ?
It's not really clear for me as i develop for the first time my own library !
Thank you very much !
Reply


Messages In This Thread
Can't acccess personnal library - by Theo - 07-22-2016, 05:06 AM
RE: Can't acccess personnal library - by Avenirer - 07-22-2016, 06:07 AM
RE: Can't acccess personnal library - by Theo - 07-22-2016, 06:22 AM
RE: Can't acccess personnal library - by Wouter60 - 07-23-2016, 01:39 AM
RE: Can't acccess personnal library - by Theo - 07-23-2016, 04:08 AM
RE: Can't acccess personnal library - by PaulD - 07-23-2016, 04:33 AM
RE: Can't acccess personnal library - by Theo - 07-24-2016, 03:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB