用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3583|回复: 3
收起左侧

資料表問題

[复制链接]
发表于 2008-2-26 15:41:37 | 显示全部楼层 |阅读模式
ci如果用跨資料表抓資料

PHP复制代码
 
$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 编辑 ]
发表于 2008-2-26 18:33:11 | 显示全部楼层
PHP复制代码
 
        // --------------------------------------------------------------------
 
        /**
         * Select
         *
         * Generates the SELECT portion of the query
         *
         * @access      public
         * @param       string
         * @return      object
         */

        function select($select = '*', $protect_identifiers = TRUE){
....
{
 
复制代码


select 好像有点问题吧
发表于 2008-2-26 18:33:16 | 显示全部楼层
至少第四行$this->db->where('stuno =',$tuno);不需要'stuno ='中的等号
 楼主| 发表于 2008-2-26 21:07:43 | 显示全部楼层
我的第四行這樣打並沒有錯

而我主要的是

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

拿出card.name這個值

但是我怎麼拿都拿不出來

有沒有誰知道阿>.<

還是有別的辦法可以拿出兩個表的值

本版积分规则