where('type', $type)->value('description'); } /** * 添加或者修改详情 * @param string $description * @param int $product_id * @param int $type * @return bool|\think\Model|static * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function saveDescription(string $description = '', int $product_id = 0, int $type = 0) { $description = htmlspecialchars($description); if ($product_id) { $info = self::where(['product_id' => $product_id, 'type' => $type])->find(); if ($info) { $info->description = $description; return $info->save(); } } return self::create(compact('description', 'product_id', 'type')); } }