I select one table but in the error section it show me that I have selected another table.I don't know why this happens.I do query in some view, but there was no problem.This problem was not in everywhere.But in some of view and controller.
Here Was my MY_Model
protected function from()
{
return $this->db->from($this->_table_name);
}
protected function where()
{
if(is_array($this->_where))
{
foreach($this->_where as $where)
{
return $this->db->where($where['field_name'],$where['primary_key']);
}
}
else
{
return $this->db->where($this->_field_name,$this->_primary_key);
}
}
protected function or_where()
{
if(is_array($this->_where))
{
foreach($this->_where as $where)
{
return $this->db->or_where($where['field_name'],$where['primary_key']);
}
}
else
{
$this->db->or_where($this->_or_field_name,$this->_or_primary_key);
}
}
protected function join()
{
if(is_array($this->_join))
{
foreach($this->_join as $join)
{
return $this->db->join($join['table'],$join['query']);
}
}
else
{
return 'Invalid Query';
}
}
protected function order()
{
//print_r($this->_order);exit();
if(is_array($this->_order))
{
return $this->db->order_by($this->_order['by'],$this->_order['order']);
}
else
{
return "Invalid Query";
}
}
protected function limit()
{
if(is_array($this->_limit))
{
foreach($this->_limit as $limit)
{
return $this->db->limit($limit['from'],$limit['to']);
}
}
else
{
return $this->db->limit($this->_limit);
}
}
public function get()
{
$this->db->select('*');
if($this->_table_name)
{
$this->from();
}
if($this->_where || ($this->_field_name && $this->_primary_key))
{
$this->where();
}
if($this->_or_where || ($this->_or_field_name && $this->_or_primary_key))
{
$this->or_where();
}
if($this->_join)
{
$this->join();
}
if($this->_order)
{
$this->order();
}
if($this->_limit)
{
$this->limit();
}
return $this->db->get();
}
And this is my query
$this->cm->_table_name = "products";
$this->cm->_field_name = "products.productID";
$this->cm->_primary_key = $productID;
$this->cm->_join = array
(
array
(
'table' => 'product_details',
'query' => 'products.productID=product_details.productID',
'type' => 'left',
),
);
$data['product'] = $this->cm->get();
this is the error
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM 'products', 'parentcategory' WHERE 'products'.'productID' = '30'' at line 1
SELECT *, * FROM `products`, `parentcategory` WHERE `products`.`productID` = '30'
Filename: C:/xampp/htdocs/mv/system/database/DB_driver.php
Line Number: 691
I don't know why this happens please help me.