V
V
Vitaly Petrov2013-06-04 06:10:16
Yii
Vitaly Petrov, 2013-06-04 06:10:16

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);

So everything works, but I do not like the way I achieved the result. Tell me something?
Oh yes, so that questions immediately disappear why I need this - I implement the ability to edit database tables and, accordingly, there is a need to update data models.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mobyman, 2013-06-04
@Mobyman

Removed.

I
Ilya Plotnikov, 2013-06-04
@ilyaplot

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 question

Ask a Question

731 491 924 answers to any question