<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [thinkphp - 虛無縹緲的云 - 博客園 (cnblogs.com)](https://www.cnblogs.com/lichihua/p/9477845.html) product\_image?? 商品圖片表: ![](https://img.kancloud.cn/13/d1/13d1a384014db364b88e710e44c5c91c_408x307.png) product\_property??商品屬性表 ![](https://img.kancloud.cn/02/6a/026ab58d59690fe54a937cc23d42e3df_575x196.png) product? ?商品表: ![](https://img.kancloud.cn/94/af/94af42762696f1a7bd03d01c80008143_855x265.png) ``` //product->controller //獲取單個商品 public function getOne($id) { (new IDMustBePositiveInt())->goCheck(); $product=ProductModel::getProductDetail($id); //$product的mysql數據為空很能是getProductDetail方法里沒有添加find(), if(!$product){//(這里返回的是think\db\Query對象)這里判斷的時候一定要確定返回的是不是數據集 如果是則用$product_isEmpty()判斷 throw new ProductException(); } return $product; } //product->model public static function getProductDetail($id) { //千萬不能在with中加空格,否則你會崩潰的 //多個關聯第一個參數里用,隔開,參數名就是下面定義關聯的的方法 //如果不報錯獲取不到 properties 的話可能是 ProductProperty模型里定義的表名不正確(protected $table='...')、或者with('imgs','properties')這種 //imgs.imgUrl:當前模型的imgs方法關聯了ProductImage模型,而ProductImge模型的imgUrl方法又關聯了Image模型 so... $products=self::with('imgs.imgUrl,properties')->find($id); //或者這種寫法 //$products=self::with(['imgs.imgUrl','properties'])->find($id); //又或者: /* $products=self::with(['imgs.imgUrl']) ->with(['properties']) ->find($id); */ //無法進行排序需要修改如下 $products=self::with([ 'imgs'=>function($query){ $query->with(['imgUrl']) ->order('order','asc'); } ])->with(['properties']) ->find($id); return $products; } /** * 關聯商品詳圖 * call to a member funftion eagerlyResult() 當沒有加return返回時 報此錯 * @return [type] [description] */ public function imgs() { return $this->hasMany('ProductImage','product_id','id'); } /** * 關聯商品屬性 * @return [type] [description] */ public function properties() { return $this->hasMany('ProductProperty','product_id','id'); } //ProductImage ->model class ProductImage extends BaseModel{ protected $table='product_image'; protected $hidden=['img_id','detele_time','product_id']; //關聯image public function imgUrl() { return $this->belongsTo('Image','img_id','id'); } } //ProductProperty ->model class ProductProperty extends BaseModel{ protected $table='product_property'; protected $hidden=['product_id','detele_time','id']; } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看