benbenhu007
- benbenhu007 收藏了教程Yii2下验证码的切换
- benbenhu007 收藏了问题Yii2.0 数据查询问题
- benbenhu007 赞了回答
\yii\helpers\ArrayHelper::getColumn(Brand::find()->orderBy('order')->select('name')->asArray()->all(), 'name')
- benbenhu007 回答了问题 快速调用数据库的方法?
* $locator = new \yii\di\ServiceLocator; * $locator->setComponents([ * 'db' => [ * 'class' => 'yii\db\Connection', * 'dsn' => 'sqlite:path/to/file.db', * ], * 'cache' => [ * 'class' => 'yii\caching\DbCache', * 'db' => 'db', * ], * ]); * * $db = $locator->get('db'); // or $locator->db
yii2默认的db连接是读取的数据库配置 如果不想用的话 你可以写原生的mysql_connect() 但是感觉没必要 它自带的就很好用