[eluser]arjo[/eluser]
Hi,
I try to perform a select on joined tables but it won't work.
This is the code:
Code:
class MDocuments extends IgnitedRecord
{
var $table = 'documents';
var $id_col = 'document_ID';
var $belongs_to = array
(
array('table' => 'doctypes', 'name' => 'doctype', 'fk' => 'doctype_ID'),
);
function getAllDocuments($doctype)
{
$this->join_related('doctype', array('name'));
$this->where('doctype_name',$doctype);
return $this->find_all();
}
}
produces the following error:
A Database Error Occurred
Error Number: 1054
Unknown column 'doctype_name' in 'where clause'
SELECT `doctype`.`name` AS `doctype_name`, `documents`.* FROM `documents` LEFT JOIN `doctypes` AS `doctype` ON documents.doctype_ID = doctype.doctype_ID WHERE `doctype_name` = 'public'
Anybody with an idea wat I am doing wrong? (and a solution
Thanks in advance,
Arjo