Welcome Guest, Not a member yet? Register   Sign In
help needed on join_related
#1

[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 Smile

Thanks in advance,

Arjo
#2

[eluser]Fatih[/eluser]
Do you have a column as named as doctype_name in your database?
#3

[eluser]Johan André[/eluser]
This is the wrong place dude!
I don't see how anyone can use the code you supplied (which is what the "Ignited Code"-forum is all about).

If you have a problem you cannot solve by reading the CI userguide, the ignited record userguide or the manuals (PHP & MySQL), post it in "Code and Application" (or atleast in the Ignited Record thread of this forum).
#4

[eluser]arjo[/eluser]
[quote author="Johan André" date="1247087367"]This is the wrong place dude!
I don't see how anyone can use the code you supplied (which is what the "Ignited Code"-forum is all about).

If you have a problem you cannot solve by reading the CI userguide, the ignited record userguide or the manuals (PHP & MySQL), post it in "Code and Application" (or atleast in the Ignited Record thread of this forum).[/quote]

SORRY!!!!!!!!
#5

[eluser]Johan André[/eluser]
[quote author="arjo" date="1247090183"]

SORRY!!!!!!!![/quote]

No problem!
I don't wanna be harsh, but there forums will be alot more useful if we post in the right places. Hope you find a solution to your problem! Smile




Theme © iAndrew 2016 - Forum software by © MyBB