Welcome Guest, Not a member yet? Register   Sign In
IR doesn't work properly with non-default settings
#1

[eluser]dxrsm[/eluser]
(EDIT)
I guess I should not have created a new thread...
This probably belongs to http://ellislab.com/forums/viewthread/78305/P320/
sorry for that....
(EDIT)

Hello,
I am testing IR on a predefined mysql schema. That means that I have to define non-default settings. I have users and userprofiles tables defined with innoDB and relations. There is a one-to-one relationship between them.
So I define these derived classes:

Code:
class User extends IgnitedRecord{
    var $table = "users";
    var $name = "user";
    var $id_col = "userID";
    var $has_one = array('table'=>'userprofiles', 'name'=>"userprofile");
}

class Userprofile extends IgnitedRecord{
    var $table = "userprofiles";
    var $name = "userprofile";
    var $id_col = "userProfileID";    
    var $belongs_to = array('table'=>'users', 'name'=>'user', 'fk'=>'userID');
}

In the controller I have a function defined as:

Code:
function index(){
    $this->load->library('ignitedrecord/ignitedrecord');
    $this->load->model('user');
    $this->load->model('userprofile');
        
    $rec =& $this->user->find(1);
      
    echo $rec->username;
        
    $rel =& $rec->related("userprofile");
        
    $r = $rel->get();

    echo $r->email;          
    }

I get the following error:

Quote:A Database Error Occurred

Error Number: 1054

Unknown column 'userprofile.user_id' in 'where clause'

SELECT `userprofile`.* FROM `userprofiles` AS `userprofile` WHERE `userprofile`.`user_id` = '1' LIMIT 1

I have to note that when i print_r the $rec object i get a *RECURSION*.
Also, when I call $rel = $rec->join_related("userprofile"), i get an error that:
Quote:IR_record: Method join_related() is not found.

I am using IgnitedRecord 1.0 pre_release (rev218).
I have included ignitedrecord and ignitedquery.php in libraries folder, and I'm running php5.
Is IgnitedRecord not suited for this kind of db setup?
I am taking a break... :down:
Any help much appreciated.
Thank you very much
#2

[eluser]m4rw3r[/eluser]
Has been solved here: http://ellislab.com/forums/viewreply/497547/




Theme © iAndrew 2016 - Forum software by © MyBB