csa12/yii2-data

Yii 2.0 database additions

dev-master 2015-10-31 16:19 UTC

This package is not auto-updated.

Last update: 2024-04-13 15:12:08 UTC


README

These database additions for Yii 2.0 add certain features
for development purposes by CSA and can perhaps be of use to others.

This repository is available via https://github.com/csa12/yii2-data. For license information check the LICENSE-file.

Installation

The preferred way to install is through composer.

Either run

composer require csa12/yii2-data

or add

"csa12/yii2-data": "dev-master",

to the require section of your composer.json.

Usage

To use this extension, simply add the following code at the beginning of views/layouts/main.php or any other view file where you would like to check your database connection or table(s) existence.

use csa\data\Database;

<?php 
	$tableNames = ['name_of_database_table1', 'name_of_database_table2'];//or []
	$db = Database::checkDb($tableNames);
	$this->beginPage() ?>
...

And if so desired you can disable showing your content, when the database or table is not found, by adding the following code around the within views/layouts/main.php

...
        <?php if ($db) { ?>
        <?= $content ?>
        <? } ?>
...

Note

This version is still under development and not intended for use in any production evironments.