在 Yii 中获取 PrimaryKey 的值
我的数据库是这样的
=== Group ===
id(Pk)
member_id(Fk)
description
=== Member ===
id(Pk)
firstname
lastname
现在我要在组控制器中定义成员。因此,我将成员定义为类似的
$members = Members::model()->findAllByPk(array('id','condition'=>'Group=member_id','params'=>array('member_id'=>$member)));
但它不起作用并显示错误尝试获取非对象的属性
。有人可以告诉我如何满足该条件。
My database is something like this
=== Group ===
id(Pk)
member_id(Fk)
description
=== Member ===
id(Pk)
firstname
lastname
Now I am going to define Member in Groups controller. So there I have defined the Member as like
$members = Members::model()->findAllByPk(array('id','condition'=>'Group=member_id','params'=>array('member_id'=>$member)));
But it is not working and showing error Trying to get property of non-object
.Can someone tell me how to make that condition satisfy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来你正在传递 invlaid 参数。请参阅文档。第一个参数应该是 id (或 ids 数组),第二个条件(或条件对象),然后是绑定参数。
Well seems like you are passing invlaid arguments. See documentation. The first argument should be id (or array of ids), the second condition (or criteria object) and then bound parameters.