Answer the question
In order to leave comments, you need to log in
Calling Gii from your code?
Hello.
I need to call the regeneration of models from my own code, it would be nice to do this by calling gii through a certain method.
Unfortunately, all my attempts to find something similar in Gii itself or call it with the help of messing around with get / post requests were unsuccessful.
I had to use the yiic shell, but everyone knows that it is obsolete and its use is not welcome. and it’s just that I don’t feel like calling the model generation methods from the console, now I have to do something like this:
$protectedPath = Yii::app()->basePath . '/';
$modelsPath = $protectedPath . "models/";
$modelFilePath = $modelsPath . get_class($this) . ".php";
$yiicFilePath = $protectedPath . "yiic";
$configFilePath = $protectedPath . "config/console.php";
unlink ($modelFilePath);
$out = shell_exec('echo "nmodel ' . get_class($this) . ' ' . $this->tableName() . '" | ' . $yiicFilePath . ' shell ' . $configFilePath);
Answer the question
In order to leave comments, you need to log in
I use CreateTable and the simplest self-written php constructor of the model file.
www.yiiframework.com/doc/guide/1.1/en/database.query-builder#sec-5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question