kfrico 发表于 2008-2-26 15:41:37

資料表問題

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 编辑 ]

lony 发表于 2008-2-26 18:33:11


        // --------------------------------------------------------------------

        /**
       * Select
       *
       * Generates the SELECT portion of the query
       *
       * @access        public
       * @param        string
       * @return        object
       */
        function select($select = '*', $protect_identifiers = TRUE){
....
{


select 好像有点问题吧

kissmumu 发表于 2008-2-26 18:33:16

至少第四行$this->db->where('stuno =',$tuno);不需要'stuno ='中的等号

kfrico 发表于 2008-2-26 21:07:43

我的第四行這樣打並沒有錯

而我主要的是

foreach($eret->result() as $row)

拿出card.name這個值

但是我怎麼拿都拿不出來

有沒有誰知道阿>.<

還是有別的辦法可以拿出兩個表的值
页: [1]
查看完整版本: 資料表問題