echo 输出sql JOIN?
echo
应该如何输出以下查询?
我在 MySQL 数据库中的表:
$query = $this->db->query('SELECT geo.order FROM Store_Information si JOIN Geography AS geo ON geo.id = si.id WHERE si.name LIKE "%' . $find1 . '%"');
我的尝试不起作用:
if ($query->num_rows() > 0){
foreach($query as $val) {
$query_out = $query->row();
echo $query_out->order . '<br>';
}
}
else {
echo '0';
}
我该怎么办?
How should echo
output following query?
My tables in MySQL database:
$query = $this->db->query('SELECT geo.order FROM Store_Information si JOIN Geography AS geo ON geo.id = si.id WHERE si.name LIKE "%' . $find1 . '%"');
My try not work:
if ($query->num_rows() > 0){
foreach($query as $val) {
$query_out = $query->row();
echo $query_out->order . '<br>';
}
}
else {
echo '0';
}
What do I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在
foreach
循环中添加->result()
:http://codeigniter.com/user_guide/database/results.html
You need to add
->result()
in yourforeach
loop:http://codeigniter.com/user_guide/database/results.html
您应该阅读本指南,以更好地了解如何使用 codeigniter 查询结果。
基本上这段代码可以提供帮助:
并且不要忘记
$query->free();
你的结果You should read this guide to better understand how to use codeigniter query results.
basically this code can help:
and don't forget to
$query->free();
your result