[eluser]theprodigy[/eluser]
I have a similar error using the
where_join_field function.
I am using DMZ 1.7.1 Rev. 395 (per the library header)
Receiving Error:
Quote:A Database Error Occurred
Error Number: 1054
Unknown column 'pages_stylesheets.page_id' in 'where clause'
SELECT * FROM (`stylesheets`) WHERE `pages_stylesheets`.`page_id` = 1 OR `stylesheets`.`sitewide` = '1'
My code follows:
Controller:
Code:
$this->obj = new Page();
$this->obj->get_by_name($page_name); // $page_name passed in as parameter. No issue finding page.
$this->css = new Stylesheet();
$this->js = new Javascript();
$this->css->where_join_field('pages','page_id', $this->obj->id)->or_where('sitewide', '1')->get();
Stylesheet Model:
Code:
class Stylesheet extends DataMapper
{
var $has_many = array('page');
var $validation = array(
'name' => array(
'label' => 'Name',
'rules' => array('required', 'trim', 'max_length' => 255),
),
'path' => array(
'label' => 'Path',
'rules' => array('required', 'trim', 'max_length' => 255),
),
'sitewide' => array(
'label' => 'Sitewide',
'rules' => array('trim', 'callback_check_sitewide'),
)
);
public function __construct($id = NULL)
{
parent::__construct($id);
}
private function check_sitewide($var)
{
if($var == '1')
{
return true;
}
return false;
}
}
Javascript Model:
Code:
class Javascript extends DataMapper
{
var $has_many = array('page');
var $validation = array(
'name' => array(
'label' => 'Name',
'rules' => array('required', 'trim', 'max_length' => 255),
),
'path' => array(
'label' => 'Path',
'rules' => array('required', 'trim', 'max_length' => 255),
),
'sitewide' => array(
'label' => 'Sitewide',
'rules' => array('trim', 'callback_check_sitewide'),
)
);
public function __construct($id = NULL)
{
parent::__construct($id);
}
private function check_sitewide($var)
{
if($var == '1')
{
return true;
}
return false;
}
}