yii2

How to connect to an RDS database from Yii2?

落爺英雄遲暮 提交于 2019-12-12 06:36:15
问题 I have deployed a Yii2 based app onto AWS Elastic Beanstalk, also I have created the RDS instance with a database (it already has tables) on Elastic Beanstalk. However I received this error: "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known" All the files are uploaded correctly to the AWS instance. The file /common/config/main-local.php has: 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=', 'dsn' => 'mysql:host

SwiftMailer Connection could not be established with host

旧时模样 提交于 2019-12-12 06:08:45
问题 I am getting an unexpected problem with emails being sent from my site. It had been working fine for some time and all of a sudden seems to have stopped for no apparent reason. [Swift_TransportException] exception 'Swift_TransportException' with message 'Connection could not be established with host [Connection timed out #110]' in vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:265 In my web.php 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'transport' => [

Yii2 model search between query

烂漫一生 提交于 2019-12-12 05:57:53
问题 I Want to impliment below mysql query in yii2 model search() SELECT * FROM `parking_availability` WHERE ('09:00' BETWEEN `time_start` AND `time_end` ) AND ( '11:00' BETWEEN `time_start` AND `time_end` ) I have applied like this $query->andFilterWhere([$this->arrivaltime,'between','time_star', 'time_end']) ->andFilterWhere([$this->departuretime,'between','time_star', 'time_end']); But its showing error Operator '09:00' requires two operands. Please help me , Thanks 回答1: You were in the right

How to load class at every page load in advanced app

≯℡__Kan透↙ 提交于 2019-12-12 05:48:01
问题 I want to have class in which I would put all my methods that should run everytime someone loads a page, lets call it InitRoutines. In yii2 basic app I would do something like this. I would add class to compontents config file, and add it to bootstrap, simple as that. But I can not figure out how to do it in advanced app, preferable in common/config config.php $config = [ // .. 'components' => [ 'InitRoutines' => [ 'class' => 'app\commands\InitRoutines', ], ], ]; $config['bootstrap'][] =

Installing Yii2 Starter Kit under Localhost

末鹿安然 提交于 2019-12-12 05:38:26
问题 I am a complete newbie at Yii2 Frameworks and I have been recommended to install the Yii2 Starter Kit to get a web framework up fast (see https://github.com/trntv/yii2-starter-kit). I am trying to install the kit in a local development environment with PHPStorm and the in-built web-server. I have followed all the (applicable) instructions in the setup guide here: https://github.com/trntv/yii2-starter-kit/blob/master/docs/installation.md#important-notes After installation, I can't seem to

MySQL Column definition for hasMany relationship in Yii2

主宰稳场 提交于 2019-12-12 05:33:44
问题 I have an employees table defined with their alphanumeric employee_id (currently 9-characters but can increase upto 15) as the key: CREATE TABLE employee ( emp_id VARCHAR(15) NOT NULL PRIMARY KEY, emp_name VARCHAR(255) NOT NULL, ... ); Now, I've to create a Group entity where each employee can be part of multiple groups: CREATE TABLE group ( group_id VARCHAR(15) NOT NULL PRIMARY KEY, group_name VARCHAR(255) NOT NULL, employees ????, <--- how should this be defined? FOREIGN KEY fk_emp

Why my dropdown list can't be position in center?

萝らか妹 提交于 2019-12-12 05:22:07
问题 I want to make the position of my dropdown list to be center. But when I made align="center" the posistion isn't in the center Here is my codes: <?php /* @var $this yii\web\View */ $this->title = 'Beranda - Pascasarjana Dalam Angka'; ?> <div class="site-index"> <div class="jumbotron"> <h1>Selamat Datang!</h1> <p class="lead-lg-5">Aplikasi ini ditujukan untuk menampilkan <br>data-data dan statistik mahasiswa program Pascasarjana Universitas</p> <div align="center" class="body-content"> <div

onchange function in dropDownList yii2

て烟熏妆下的殇ゞ 提交于 2019-12-12 05:19:13
问题 I have a function (getArticleByFamille) in event onchange dopDownList like this: <?= $form->field($modelFamille, 'idFamille')->dropDownList( ArrayHelper::map(Famille::find()->all(), 'idFamille', 'libelle'), [ 'prompt' => 'Sélectionner la Categorie', 'class' => 'chosen-select mb-15', 'onchange' => 'getArticleByFamille(this.value,"vente/devis","' . Yii::$app->getUrlManager()->getBaseUrl() . '","ArticleByFamille")' ] )->label(false); ?> but When I call this function, it not working and when I

Call to a member function saveAs() on null(does't work skipOnEmpty)

喜夏-厌秋 提交于 2019-12-12 05:08:42
问题 I can't update a page without of upload image.Even if I write skipOnEmpty in the rules it doesn't work . What do I wrong? This is a controller if ($model->load(Yii::$app->request->post())){ //represent the uploaded file as an instance $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); //save path to image in db $model->image = '/images/' . $model->imageFile->baseName . '.' . $model->imageFile->extension; //save changes in db $model->save(); //upload image on server $model-

Yii2 Query does not return column sum

廉价感情. 提交于 2019-12-12 05:08:10
问题 I have this code, example: $rows = Category::find() ->select('id_category, SUM(p.comments * 10) AS num') ->leftJoin('post p', 'p.id = post_id') ->groupBy('id_category') ->one(); This exist: $rows->id_category But this not exist: $rows->num 回答1: You need a field named 'num' in your Category model otherwise you can't access to this value. add the public var $num this way class Category extends \yii\db\ActiveRecord { public $num; /** * @inheritdoc */ public static function tableName() 来源: https: