如何用SQL Block解释这个CodeIgniter? [英] How to interpret this CodeIgniter with SQL Block?
本文介绍了如何用SQL Block解释这个CodeIgniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在分析这个sql代码:
Hi,
I've been analyzing this sql code:
$this->db->select('ut.Username,ct.Title,ct.ContentID',false);
$this->db->from('username_table AS ut');
$this->db->join('content_table AS ct', 'ct.UserID = ut.UserID');
$query = $this->db->get('content_table');
return $query->result_array();
我的content_table中只有5行,但当我转换返回的查询时,它回应25,为什么会这样?
已添加代码块:
也许这会让事情更简单,但有没有办法只调用特定列用作foreach的计数机制,例如:
I only have 5 rows in my content_table, but when I convert the returned query it echos 25, why is that?
ADDED Codeblock:
Maybe this will make things simplier but is there a way to just call the specific column to be use as a counting mechanism for the foreach something like:
foreach($contents.GETCOLUMNHERE as $contents_item)
所以我只需要调用内容列来循环计数?
so I'll just call the content column to mach the loops count?
<?php foreach ($contents as $contents_item):
?>
<h2><?php echo $contents_item['Title'] ?></h2>
<div id="main">
<?php echo $contents_item['Username'] ?>
</div>
<p><a href="contents/<?php echo $contents_item['ContentID'] ?>">View article</a></p>
<?php endforeach ?>
推荐答案
this-> db-> select(' ut.Username,ct.Title,ct.ContentID',false);
this->db->select('ut.Username,ct.Title,ct.ContentID',false);
this-> db-> from(' username_table AS ut');
this->db->from('username_table AS ut');
this-> db-> join('' content_table AS ct',' ct.UserID = ut .UserID'跨度>);
this->db->join('content_table AS ct', 'ct.UserID = ut.UserID');
这篇关于如何用SQL Block解释这个CodeIgniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文