[moka学习笔记]yii2.0数据库查询的多种方法(未完待整理)

方法一:(使用model)

$modelCommunityMail = CommunityMail::find()->where(['com_id'=>$id])->all();

方法二:(直接拼写sql语句)

$sql = "select * from `usho_community_mail` where date_format(`created_at`,'%Y%m') = date_format(curdate() ,'%Y%m')
                AND `com_id`=$id AND `is_deleted`=0 ";
        $modelCommunityMail = Yii::$app->db->createCommand($sql)->queryAll();
我生活的地方,我为何要生活。
原文地址:https://www.cnblogs.com/hsd1727728211/p/5870964.html