Codeigniter返回值
我是 Codeigniter 和 PHP 的新手。
在做一些操作时我有一些疑问,特别是在数据库中。
$get = "select filed_1 from tbl_ctc where ctc=?";
$get = $this->db->query($get,array($ctc_n));
if ($get)
{
//do some operations
}
else
{
//do some another operations
}
如果成功的话$get的返回值是多少?
期待意见&建议[也反对]
谢谢。
I am new to Codeigniter and PHP..
while doing some operations i have some doubts ,especially in the database libraries .
$get = "select filed_1 from tbl_ctc where ctc=?";
$get = $this->db->query($get,array($ctc_n));
if ($get)
{
//do some operations
}
else
{
//do some another operations
}
What will be the return value of $get if it is success ?
Expecting opinion & suggestion [downvotes too]
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您期待什么“意见和建议”?
当您使用读取查询(例如选择)时,query()方法返回一个结果对象,而使用写入查询(例如插入或插入)更新)它返回 TRUE 或 FALSE。
在 SELECT 的情况下,即,您可能想检查它是否有任何结果:
而在 INSERT 的情况下,例如:
请注意,如果您使用的是 Active Record,您将获得 result() /
row()
和result_array()
/row_array()
方法将返回完整对象/数组或空数组一个,所以你需要检查那些值代替。What "opinions and suggestions" do you expect?
The query() method returns a result object when you use read queries (like a select), while with write queries (like an insert or update) it returns TRUE or FALSE.
In case of a SELECT, i.e., you might want to check if it has any result:
While, in case of an INSERT for ex.:
Note that if you are using Active Record, you'll have the
result()
/row()
andresult_array()
/row_array()
methods that will return either a full object/array or an empty one, so you'll need to check for those values instead.结果将是一个对象。您必须更进一步才能获得预期值,例如
请参阅 Active Record Class 和用户指南中的示例以供进一步参考。
The result will be an object. You have to go one step further to get the expected value, e.g.
See Active Record Class and examples from the user guide for further reference.