2
我有一个关系的建立是这样的:我怎样才能递归找到cakePHP?
class Geocache extends AppModel {
var $belongsTo = 'User';
var $hasMany = 'Log';
}
class Log extends AppModel {
var $belongsTo = array('User','Geocache');
}
class User extends AppModel {
var $hasMany = array('Geocache','Log');
}
和$this->Geocache->find('first');
回报:
Array
(
[Geocache] => Array
(
[id] => 86
[user_id] => 3
[name] => Hejssa
//...
)
[User] => Array
(
[id] => 3
[username] => Ahtenus
//...
)
[Log] => Array
(
[0] => Array
(
[id] => 1
[user_id] => 12
// How do i retrive the username and such from the User table together with this?
[geocache_id] => 86
//...
)
//...
)
)
我如何也得为每个登录用户的数据?
只要将递归设置为1以上,我就会得到这个奇怪的错误:致命错误:无法在/var/www/ccache/app/models/geocache.php行中将字符串偏移量用作数组“你知道这可能是什么原因吗? – Ahtenus
你能发表该文件的第94行(和环境)吗? – JJJ
对不起,混淆了模型和控制器,并看着错误的文件。我会自己修复它,但无论如何感谢。 – Ahtenus