本文整理匯總了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]);');
}
}