本文整理汇总了PHP中DibiConnection::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::__construct方法的具体用法?PHP DibiConnection::__construct怎么用?PHP DibiConnection::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DibiConnection
的用法示例。
在下文中一共展示了DibiConnection::__construct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constractor creates connection and checks/creates tables stucture
*/
public function __construct()
{
$dibiConfig = dibi::getConnection()->getConfig();
$dbname = isset($dibiConfig['dbname']) ? $dibiConfig['dbname'] : $dibiConfig['database'];
$config = array('driver' => 'sqlite', 'profiler' => Environment::getConfig('perform')->storage_profiler, 'database' => realpath(Environment::getConfig('perform')->modelCache) . '/' . $dbname . '-storage.sdb');
parent::__construct($config, 'storage');
if (!$this->getDatabaseInfo()->hasTable('fields')) {
$this->query('CREATE TABLE [fields] ([id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
[hash] VARCHAR(32) NOT NULL, [type] VARCHAR(50));
CREATE UNIQUE INDEX [fields_idx] on [fields] ( [name], [table]);');
}
if (!$this->getDatabaseInfo()->hasTable('tables')) {
$this->query('CREATE TABLE [tables] ( [id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
}
if (!$this->getDatabaseInfo()->hasTable('views')) {
$this->query('CREATE TABLE [views] ( [id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL UNIQUE, [hash] VARCHAR(32) NOT NULL);');
}
if (!$this->getDatabaseInfo()->hasTable('indexes')) {
$this->query('CREATE TABLE [indexes] ([id] INTEGER NOT NULL PRIMARY KEY,
[name] VARCHAR(100) NOT NULL, [table] VARCHAR(50) NOT NULL,
[hash] VARCHAR(32) NOT NULL, [unique] BOOLEAN);
CREATE UNIQUE INDEX [indexes_idx] on [indexes] ( [name], [table]);');
}
}