-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
table prefix in model generator #8
Comments
There was a discussion in the yii2 repo about this, it may be a default setting from an older version (either Connection or in the app config). Can't you set a |
this worked fine in yii-gii and GiixModel Generator. |
Do you have the latest Yii 2 version (dev-master)? There was an issue here: yiisoft/yii2#2922, yiisoft/yii2#2911 What changes when you check the |
TablePrefix in 'db' works as expected ... |
Please send a PR if this is a general fix. |
Custom table prefix added in 513cf79 |
There's a checkbox ... I am not 100% sure, but I think Yii is always using the connection prefix from the database. While giiant allows you to specify a table prefix, just for CRUD generation. I'll clarify this and update the docs. |
@schmunk42 thank you for your answer. I am in the process of migrating from Cake Php to YII. I want to know where to put the prefix, in what file. |
Do you need a prefix for your database connection? You put that setting in the application config |
wow, that is great documentation! |
Edit in db.php : 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname= ******_', 'username' => '**_**_', 'password' => '**_****_', 'charset' => 'utf8', 'tablePrefix' => '**_**_' ]; Then generate CRUD. After that generate Model with option "Use Table Prefix" (Check) Voila tout. PS In models you can see like public static function tableName() { return '{{%tablename_without_prefix}}'; } |
I used Giiant for CRUD generation, it didnt create any model :( I get error like: Class 'app\modules\crud\models\Faq' not found |
Did you use the Web UI or the CLI batch command? Does the table in the used db connection exists?! Could you give some more information about your configuration? |
I used the CLI command "yii batch". I updated console->config->main.php with 'controllerMap' as under:
The class backend\crud\models\base\Faq.php has the following function:
I am getting this error: Class 'app\models\query\FaqQuery' not found |
Double check your namespaces.
and
do not match. Von meinem iPhone gesendet
|
Where shud I check ? Please guide that I have placed the batch config in the right place i.e. in console->config->main.php ? Actually FaqQuery does exist in \app\models\query\ namespace. But still it says, class not found. Schmunk I love your module giiant-yii2. I have been using it in all of my projects. Great piece :) |
Thank you 🙇 Sorry I mixed up the namespace paths... Could you try setting the |
or look at the example and way we do it here: 'https://github.com/phundament/app/blob/master/src/config/giiant.php' with application config 'https://github.com/phundament/app/blob/master/src/config/main.php' |
I am using Yii2 advanced app. So "CLI configuration" in advanced app would mean console->config->main.php ? |
exactly ;-) just merge your giiant.php configuration file into your console->config->main.php. cheers chris |
after install via composer and setup everything looks fine so far.
need to use table prefix in my db (provider),
just didn't find any config docs in giiant and generating with "tbl_*" gives me
models with "TblTableName" where "TableName" is suggested
The text was updated successfully, but these errors were encountered: