本文整理匯總了PHP中dibi::getDatabaseInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::getDatabaseInfo方法的具體用法?PHP dibi::getDatabaseInfo怎麽用?PHP dibi::getDatabaseInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::getDatabaseInfo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: indexAction
/**
*
*/
public function indexAction()
{
die('todo');
$overwrite = !is_null(Core_Request::getInstance()->getArgv(4)) ? Core_Request::getInstance()->getArgv(4) : false;
foreach (dibi::getDatabaseInfo()->getTables() as $table_data) {
if ($table_data->getName() == Migration_MigrationModel::getTableName()) {
continue;
}
$ddl_data = dibi::query('SHOW CREATE TABLE ' . $table_data->getName())->fetch()->toArray();
$ddl_query = $ddl_data['Create Table'];
$migration_time = time();
$migration_name = 'Create' . ucfirst($table_data->getName());
$migration_name = str_replace(' ', '', $migration_name);
$migration_name = str_replace('-', '', $migration_name);
$migration_name = str_replace('_', '', $migration_name);
$filename = cfg()->migration_path . $migration_name . '.php';
if (Core_Files::fileSize($filename) && !$overwrite) {
echo PHP_EOL . 'Migration "Create ' . ucfirst($table_data->getName()) . '" Exists' . PHP_EOL;
continue;
}
$template_data = Core_Files::getContent(cfg()->migration_path . Migration_FilesHelper::TEMPLATE_FILE_NAME);
$template_data = str_replace('Template', $migration_name, $template_data);
$template_data = str_replace('__NAME__', $migration_name, $template_data);
$template_data = str_replace('__CREATED_AT__', $migration_time, $template_data);
$template_data = str_replace('__CREATED_CFG__', Core_Request::getInstance()->getArgv(1), $template_data);
$template_data = preg_replace('#//__UP_ACTION__#', $ddl_query, $template_data);
$down_query = 'DROP TABLE IF EXISTS `' . $table_data->getName() . '`';
$template_data = preg_replace('#//__DOWN_ACTION__#', $down_query, $template_data);
Core_Files::putContent($filename, $template_data);
echo PHP_EOL . 'Migration ' . $filename . ' created' . PHP_EOL;
}
}
示例2: foreach
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<h1>Database Reflection | dibi</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
// retrieve database reflection
$database = dibi::getDatabaseInfo();
echo "<h2>Database '{$database->name}'</h2>\n";
echo "<ul>\n";
foreach ($database->getTables() as $table) {
echo '<li>', ($table->view ? 'view' : 'table') . " {$table->name}</li>\n";
}
echo "</ul>\n";
// table reflection
$table = $database->getTable('products');
echo "<h2>Table '{$table->name}'</h2>\n";
echo "Columns\n";
echo "<ul>\n";
foreach ($table->getColumns() as $column) {
echo "<li>{$column->name} <i>{$column->nativeType}</i> <code>{$column->default}</code></li>\n";
}
echo "</ul>\n";
echo "Indexes";
echo "<ul>\n";
foreach ($table->getIndexes() as $index) {
echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' (';
foreach ($index->getColumns() as $column) {
echo "{$column->name}, ";
示例3: storageExists
/**
* Does the configuration storage exist?
* Will return true if all schema objects are available.
*
* @see server/classes/AbstractAjxpUser#storageExists()
* @return boolean false if storage does not exist
*/
function storageExists()
{
$this->log('Checking for existence of AJXP_User storage...');
try {
$dbinfo = dibi::getDatabaseInfo();
$dbtables = $dbinfo->getTableNames();
if (!in_array('ajxp_user_rights', $dbtables) || !in_array('ajxp_user_prefs', $dbtables) || !in_array('ajxp_user_bookmarks', $dbtables)) {
return false;
}
} catch (DibiException $e) {
return false;
}
return true;
}
示例4: storageExists
/**
* Does the configuration storage exist?
* Will return true if all schema objects are available.
*
* @see AbstractAjxpUser#storageExists()
* @return boolean false if storage does not exist
*/
function storageExists()
{
$this->log('Checking for existence of AJXP_User storage...');
try {
$dbinfo = dibi::getDatabaseInfo();
$dbtables = $dbinfo->getTableNames();
if (!in_array('ajxp_user_rights', $dbtables) || !in_array('ajxp_user_prefs', $dbtables) || !in_array('ajxp_user_bookmarks', $dbtables)) {
return false;
}
//$result_rights = dibi::query('SELECT [repo_uuid], [rights] FROM [ajxp_user_rights] WHERE [login] = %s', $this->getId());
//$this->rights = $result_rights->fetchPairs('repo_uuid', 'rights');
$this->load();
if (!isset($this->rights["ajxp.admin"])) {
return false;
}
} catch (DibiException $e) {
return false;
}
return true;
}