hasOne relation when primary and foreign key are the same

2010-09-10 Thread emmexx
I have to access some table created by others outside of cakephp.

2 of the tables are related by a hasOne relationship but the second
table has a primary key that is *the* foreign key. Please don't ask! :-
(
I can't change the tables.
I used the following models in cake:

table1:

class t1 extends AppModel {

var $name = 't1';
var $useDbConfig = 'other';
var $useTable = 'externalt1';

var $hasOne = array(
'T2' = array(
'className' = 'T2',
'foreignKey' = 'id',
'dependent' = false,
'conditions' = '',
'fields' = '',
'order' = ''
)
);
}

table2:

class T2 extends AppModel {

var $name = 'T2';
var $useDbConfig = 'other';
var $useTable = 'externalt2';
}

In the t1 controller I put a find('all'):
$this-log($this-T1-find('all')); // in index (just a test)

But when I go to T1s address I get a blank page and nothing in the log
file.

Is there a cake way to access the data of the 2 tables?

thanks
   maxx

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: hasOne relation when primary and foreign key are the same

2010-09-10 Thread cricket
On Fri, Sep 10, 2010 at 6:55 AM, emmexx emmeics...@gmail.com wrote:
 I have to access some table created by others outside of cakephp.

 2 of the tables are related by a hasOne relationship but the second
 table has a primary key that is *the* foreign key. Please don't ask! :-
 (
 I can't change the tables.
 I used the following models in cake:

 table1:

 class t1 extends AppModel {

        var $name = 't1';
        var $useDbConfig = 'other';
        var $useTable = 'externalt1';

        var $hasOne = array(
                'T2' = array(
                        'className' = 'T2',
                        'foreignKey' = 'id',
                        'dependent' = false,
                        'conditions' = '',
                        'fields' = '',
                        'order' = ''
                )
        );
 }

 table2:

 class T2 extends AppModel {

        var $name = 'T2';
        var $useDbConfig = 'other';
        var $useTable = 'externalt2';
 }

 In the t1 controller I put a find('all'):
 $this-log($this-T1-find('all')); // in index (just a test)

 But when I go to T1s address I get a blank page and nothing in the log
 file.

That may be a fatal error. If PHP craps out it won't be able to log
anything. Check your server's log.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: hasOne relation when primary and foreign key are the same

2010-09-10 Thread emmexx


On 10 Set, 20:08, cricket zijn.digi...@gmail.com wrote:

 That may be a fatal error. If PHP craps out it won't be able to log
 anything. Check your server's log.

Too lazy to check apache logs... :-(

PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted
(tried to allocate 4198401 bytes) in /var/www/htdocs/cake/libs/
object.php on line 158

It was a find('all') without limits and conditions.

Thank you
maxx

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en