You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN `pm_categories` ON `pm_products`.`category_id` = `pm_categories`.`category_' at line 2
SELECT * JOIN `pm_categories` ON `pm_products`.`category_id` = `pm_categories`.`category_id`
public $table_name = '';
public function get ($ids = FALSE){
// Set flag - if we passed a single ID we should return a single record
$single = $ids == FALSE || is_array($ids) ? FALSE : TRUE;
// Limit results to one or more ids
if ($ids !== FALSE) {
// $ids should always be an array
is_array($ids) || $ids = array($ids);
// Sanitize ids
$filter = $this->primaryFilter;
$ids = array_map($filter, $ids);
$this->db->where_in($this->primary_key, $ids);
}
// Set order by if it was not already set
//count($this->db->ar_orderby) || $this->db->order_by($this->order_by);
//$this->order_by !== '' ? $this->db->order_by($this->order_by) : '';
// Return results
$single == FALSE || $this->db->limit(1);
$method = $single ? 'row' : 'result';
return $this->db->get($this->table_name)->$method();
}
Product.php (Model)
class Product extends My_Model
{
public $table_name = 'pm_products';
public $primary_key = 'product_id';
}
Controllers
...
.
function __construct()
{
parent::__construct();
$this->load->view('admin/templates/header');
$this->load->model('admin/product');
}
function index()
{
$this->load->helper('dump');
$row = $this->product->_join('pm_categories','pm_products.category_id = pm_categories.category_id');
dump($row);
}