wunayou 发表于 2012-2-20 22:47:35

二个查询怎么相结合

本帖最后由 wunayou 于 2012-2-21 13:35 编辑

function get_product($id)
         {
               $query=$this->db->query("select * from product where brand=(select name from product_brand where id=$id)");
         
         
               return $query->result();
               
         }

function get_product($id)         {               $query=$this->db->query("select * from product where brand=(select name from product_brand where id=$id)");                                 return $query->num_rows()                        }
这二个怎么结合起来啊

大道达人 发表于 2012-2-21 09:40:12

你的结合是神马意思?

/*我的理解*/
/*result*/
        public function getProductByOption($id ='',$option='data')
        {
                $query = $this->db
                                ->query(
                                                "select * from `product`
                                               where brand=(select name from product_brand where id={$id})");

                if ( $option != 'data')
                {
                        return $this->query->num_rows();
                }
                return $this->query->result();

        }

wunayou 发表于 2012-2-21 11:51:16

大道达人 发表于 2012-2-21 09:40 static/image/common/back.gif
你的结合是神马意思?

不是了啊 我就是想把二个方法查询的结果 用一个方法把他查询出来

大道达人 发表于 2012-2-21 13:11:25

wunayou 发表于 2012-2-21 11:51 static/image/common/back.gif
不是了啊 我就是想把二个方法查询的结果 用一个方法把他查询出来


$rstCode['num'] = $this->query->num_rows();
$rstCode['data'] = $this->query->result();
页: [1]
查看完整版本: 二个查询怎么相结合