Skip to main content

Notes

(persoonlijk aantekeningen; moet nog worden uitgewerkt)

Useful extensions

https://wbraganca.com/yii2extensions

Active Records

In Controller, get data from arbitrary model;

use app\models\Examen;

$examen = examen::find()->where(['actief' => '1'])->orderBy(['datum_van' => 'SORT_DESC'])->one();

$examen = examen::find()->where(['actief' => '1'])->orderBy(['datum_van' => 'SORT_DESC'])->all();

$gesprekSoort = gesprekSoort::find()->all();

$gesprekSoort = examenGesprekSoort::findAll(['examen_id' => $id]);

$sql="delete from examen_gesprek_soort where examen_id = :examenid";
$params = array(':examenid'=> $id);
Yii::$app->db->createCommand($sql)->bindValues($params)->execute();

$sql="insert into examen_gesprek_soort (examen_id, gesprek_soort_id) values(:examenid, :gesprekid)";
$params = array(':examenid'=> $id, ':gesprekid' => $value );
Yii::$app->db->createCommand($sql)->bindValues($params)->execute();

$gesprekken = gesprekSoort::find()->where([])->joinWith('examenGesprekSoorts')->all();

Debug

https://www.yiiframework.com/wiki/793/debuging-variables-in-yii2

Voor- nadelen


LaravelYII
MVC
ModelEloquentActive Record
View/templatingBladePHP met 'Yii Snippets'
RoutingExplicietImpliciet / Expliciet
Migrations
(meer als optie)
Model creationscommand line
GUI, reverse engineered form DB
Controller Creationcommand line
GUI, create full CRUD
View creation?
GUI, create full CRUD
Documentation***
**
Active development
Add Ons / Libraries*****
Install Base (volgens Google)484,97058,800




Grootste voordeel is de GUI waarmee je reverse engineered een CRUD maakt.

Login

http://code-epicenter.com/how-to-login-user-from-a-database-in-yii-framework-2/

N:M relation

https://forum.yiiframework.com/t/please-explain-how-to-do-many-to-many-relationships-for-newcomer/29743/3


-- TEMP ---

Gebruik gii om je models en standaard CRUS's te maken.

Create CRUD

Model Classapp\models\Examen
Search Model Classapp\models\ExamenSearch
Controller Classapp\controllers\ExamenController
View pathleeg laten (wordt default waaarde)

Datepicker Install

(in project root)

change composer.dev  "minimum-stability": "dev",

composer require "nex/yii2-datepicker"

-- TEMP ---

https://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview

Bootstrap 4