How to get user ID in libraries,
User Table
Code:
| ID | username |
|---------------|
| 1 | Alex |
| 2 | Johey |
| 3 | Leos |
| 4 | Pacat |
Store Table
Code:
| ID | userID | store_picture |
|-----------------------------|
| 1 | Alex | img1.jpg |
| 2 | Johey | img3.jpg |
| 3 | Leos | img2.jpg |
| 4 | Pacat | img5.jpg |
libraries/Store.php
Code:
<?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();
}
}
}
?>
Thanks