資料表問題
ci如果用跨資料表抓資料$this->load->database();
$this->db->select('stuno','card.name as eer');
$this->db->where('stuno =',$tuno);
$this->db->from('stu');
$this->db->join('card','stu.idcard=card.idcard');
$query['eret'] = $this->db->get();
foreach($eret->result() as $row) {
print $row->stuno;
print $row->eer;
}
這樣寫有錯嗎
為什麼我run都只出現stuno
還有如果三個資料表該怎麼寫?
[ 本帖最后由 kfrico 于 2008-2-26 15:52 编辑 ]
// --------------------------------------------------------------------
/**
* Select
*
* Generates the SELECT portion of the query
*
* @access public
* @param string
* @return object
*/
function select($select = '*', $protect_identifiers = TRUE){
....
{
select 好像有点问题吧 至少第四行$this->db->where('stuno =',$tuno);不需要'stuno ='中的等号 我的第四行這樣打並沒有錯
而我主要的是
foreach($eret->result() as $row)
拿出card.name這個值
但是我怎麼拿都拿不出來
有沒有誰知道阿>.<
還是有別的辦法可以拿出兩個表的值
页:
[1]