orderRaw(‘rand()‘);
/** * 随机获取一条商品信息 * @param [type] $condition * @param [type] $field * @param [type] $limit * @return void */ public function randSkuid($condition, $field, $limit) { $result = $this->where($condition)->field($field)->orderRaw(‘rand()‘)->limit($limit)->select(); return $result ? $result->toArray() : []; }
原文地址:https://www.cnblogs.com/camg/p/11986618.html
时间: 2024-10-10 23:39:44