
yii
s听风忆雪
best QQ2276259727
展开
-
YII2 重写 primaryKey()
// 在model里 写这个方法 public static function primaryKey() { // 返回可以作为主键的列 一列 或 多列 return [ 'user_id', 'created_at', ]; } 如果没有主键 进行修改数据保存时, 或者删除时可能会报does not have a primary key. You should...原创 2022-04-11 16:44:40 · 464 阅读 · 0 评论 -
YII2生成图形验证码 给接口使用
// 使用一下验证码类use yii\captcha\CaptchaAction;...... // 定义一个方法 public function actionCaptcha() { // 实例化 传入控制器id, controller $obj = new CaptchaAction(\Yii::$app->controller->id,\Yii::$app->controller); // 自定义配置 ..原创 2022-03-31 10:33:07 · 827 阅读 · 0 评论 -
Yii2 where里不转义某个字段方法|复杂条件拼接
$query = $table::find() ->select('id') ->where([ 'and', [ 'or', ['time_type' => 1], [ 'and', [ ...原创 2022-03-11 18:16:46 · 491 阅读 · 0 评论 -
YII2查询一列数据
Model::find()->select('distinct(zp_bianhao)')->where([ 'delete' => 0,])->column();Model需要换成自己需要的 model结果原创 2022-02-21 17:36:06 · 1057 阅读 · 0 评论 -
yii2自增自减写法
$status = false; // 自增/自减数量 自减的话写成负数 $editData['quantity'] = new \Yii\db\Expression('`quantity` + 10'); // 普通修改字段 $editData['update_time'] = time(); // 条件 $where = ['id' => $id]; try{ ...原创 2021-06-30 15:09:25 · 1025 阅读 · 0 评论 -
yii执行原生查询sql
yii执行原生查询sql SELECT table_name FROM information_schema. TABLES WHERE table_schema = \'ssd_sku\' AND ta...原创 2019-07-29 17:33:15 · 1712 阅读 · 0 评论 -
Yii复杂条件查询
$obj = $this->find(); $obj->where(array( 'and', array( 'or', // 要添加的开始时间在已存在的活动里 array( ...原创 2019-09-17 14:27:51 · 375 阅读 · 0 评论