PHP code example of keygenqt / yii2-vertica
1. Go to this page and download the library: Download keygenqt/yii2-vertica library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
keygenqt / yii2-vertica example snippets
return [
//....
'components' => [
'vertica' => [
'class' => 'yii\vertica\Connection',
'dsn' => 'Driver=Vertica;Server=localhost;Database=my-database;',
'username' => 'dbadmin',
'password' => 'password-base',
],
]
];
return [
'controllerMap' => [
'migrate-vertica' => 'yii\vertica\controllers\MigrateVerticaController',
],
];
namespace app\models;
use \yii\data\ActiveDataProvider;
use \yii\vertica\ActiveRecord;
class Admins extends ActiveRecord
{
public static function tableName()
{
return 'admins';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return [
[['username', 'password_hash', 'blocked_at', 'role', 'created_at', 'updated_at'], 'safe']
];
}
//...
public function search($params)
{
$query = Admins::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['like', 'username', $this->username]);
$query->andFilterWhere(['like', 'password_hash', $this->password_hash]);
$query->andFilterWhere(['=', 'created_at', $this->created_at]);
$query->andFilterWhere(['=', 'updated_at', $this->updated_at]);
return $dataProvider;
}
}