<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Store
{
var $info=array();
public function __construct()
{
$CI =& get_instance();
$site = $CI->db->select("userID,store_background")
->where("userID", [HERE USER ID])
->get("store_info");
if($site->num_rows() == 0) {
$CI->template->error(
"You are missing the site settings database row."
);
} else {
$this->info = $site->row();
}
}
05-29-2017, 11:04 PM (This post was last modified: 05-29-2017, 11:06 PM by neuron.)
1. If u have session, get it from session $CI->session->userdata('userId')
2. u can also path it as a parameter for library
$params = array('type' => 'large', 'color' => 'red');
$this->load->library('Someclass', $params);
To work and use CodeIgniter inside a library you need to get the CI Super Object Instance.
PHP Code:
class Your_Name {
/** * @var * Holds the CI Super Object. */ private $CI;
/** * __construct () * -------------------------------------------------------------------- * * Constructor PHP 5+ * * NOTE: Not needed if not setting values or extending a Class. * */ public function __construct() { $this->CI =& get_instance(); }
}
Then when you need to access you use this.
PHP Code:
$someThing = $this->CI->yourThing();
But for user id's, information etc; Use the session.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )