[英]Kohana PHP question
I have a database with a table named shoppingcarts
. 我有一个数据库,其中有一个名为shoppingcarts
的表。 this table has the following 3 columns: 该表具有以下3列:
id, sessionid, date
I have a function ( AddProductToCart
) in my controller ( ShoppingCart
). 我的控制器( ShoppingCart
)中有一个函数( AddProductToCart
)。 Inside my function, I have this call: 在我的函数内部,我有这个电话:
$obj = ORM::factory('shoppingcart')->where('sessionID',session_id())->find();
Now, this statement runs against the shoppingcarts
table and returns a row which has the sessionid
matching the current session id (PHP's session_id()
). 现在,此语句针对shoppingcarts
表运行,并返回具有与当前会话ID匹配的sessionid
的行(PHP的session_id()
)。 But sometimes, the sessionid
does not exist in the table. 但是有时,表中不存在sessionid
。
So, how do I check the value returned by that statement to make sure that a value was returned or not? 因此,如何检查该语句返回的值以确保是否返回了值?
I'm confused. 我糊涂了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.