Welcome Guest, Not a member yet? Register   Sign In
Use Library in Model
#1

Hello,
I'm creating a custom library, like this:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
my_class {
        protected 
$SDP;
        public function 
__construct()
        {
            
$this->SDP =& get_instance();
            
$this->SDP->load->database();
        }
        public function 
test4()
        {
            
$query $this->SDP->db->get('unit');
            return 
$query->result_array();
        } 
and create this Model:
PHP Code:
<?php
class my_model extends CI_Model {

        public function 
__construct()
        {
          
$this->load->library('my_class');
        }
       public function 
test1()
        {
          
$q $this->my_class->test4();
          
var_dump($q);
        } 
Is my code follow the MVC and Codeigniter's standards for use Library and Model?
If it's wrong please help me to fix it.
Reply


Messages In This Thread
Use Library in Model - by SajadDP - 09-12-2015, 02:04 PM
RE: Use Library in Model - by ciadmin - 09-12-2015, 04:13 PM
RE: Use Library in Model - by mwhitney - 09-14-2015, 07:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB