Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
systems:yii2:modules [2018/04/05 16:36] smayr [References] |
systems:yii2:modules [2018/04/18 09:56] (current) smayr [Using Custom Database] |
{ | { |
return "{{%item_product}}"; // formatted to allow table prefix (where % goes) | return "{{%item_product}}"; // formatted to allow table prefix (where % goes) |
| |
| // NOTE: To query the raw table name, use the following: |
| // echo Yii::$app->db->schema->getRawTableName(app\models\ItemProduct::tableName()); |
| // Displays as follows (assuming 'mod_' table prefix): |
| // mod_item_product |
} | } |
| |
// instead of getting a connection from app (using Yii::$app->get('db')) | // instead of getting a connection from app (using Yii::$app->get('db')) |
$module = \Yii::$app->controller->module; | $module = \Yii::$app->controller->module; |
return $module->get("db-mod-{$module->id}"); // use private module database | return $module->get("db-mod-label"); // use private database for module 'label' |
} | } |
| |
| |
== References == | == References == |
* [[http://www.yiiframework.com/doc-2.0/guide-structure-modules.html|Yii 2.0 Guide: Creating Modules]] | * [[http://www.yiiframework.com/doc-2.0/guide-structure-modules.html|Yii 2 Guide: Creating Modules]] |
* [[https://stackoverflow.com/questions/27254540/multiple-database-connections-and-yii-2-0|Multiple Database Connections in Yii 2.0]] | * [[https://stackoverflow.com/questions/27254540/multiple-database-connections-and-yii-2-0|Multiple Database Connections in Yii 2]] |
* [[https://stackoverflow.com/questions/34051383/yii2-modules-in-advanced-template|Yii 2.0 Modules in Advanced template]] | * [[https://stackoverflow.com/questions/34051383/yii2-modules-in-advanced-template|Yii 2 Modules in Advanced template]] |
| * [[https://www.yiiframework.com/doc/guide/2.0/en/concept-autoloading|Yii 2 Class Autoloading and Namespaces]] |
* [[https://www.yiiframework.com/doc/guide/1.1/en/basics.namespace|Yii 1.1 Namespaces]] | * [[https://www.yiiframework.com/doc/guide/1.1/en/basics.namespace|Yii 1.1 Namespaces]] |
* [[https://github.com/yiisoft/yii2/issues/3647|Better configuration of frontend, backend, and common]] | * [[https://github.com/yiisoft/yii2/issues/3647|Better configuration of frontend, backend, and modules]] |
| * [[https://yii2-cookbook.readthedocs.io/structure-backend-frontend-modules/|Yii 2 Cookbook: Structure of Backend/Frontend Modules]] |