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

(07-22-2016, 06:07 AM)Avenirer Wrote: You are using CI methods inside the library without instanciating the CI. Take a look here: https://codeigniter.com/user_guide/gener...ur-library

...I am reffering to the "$this->db..." part.

Thank you very much it works !
Here is my new library :
PHP Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class 
Cms {

         public function 
__construct()
        {
                
// Assign the CodeIgniter super-object
                
$this->CI =& get_instance();
        }

        public function 
getTags($pageName)
        {
            
            
$query $this->CI->db->get_where('cms', array('page_name' => $pageName), 1);

            foreach (
$query->result_array() as $row)
            {
                    return 
$row;
            }
        }

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