1
0
mirror of https://github.com/dg/dibi.git synced 2025-07-31 19:30:30 +02:00

removed usage of magic properties

This commit is contained in:
David Grudl
2015-10-06 13:14:01 +02:00
parent 7c1f735f9b
commit 59223d937d
5 changed files with 39 additions and 39 deletions

View File

@@ -16,10 +16,10 @@ dibi::connect([
// retrieve database reflection
$database = dibi::getDatabaseInfo();
echo "<h2>Database '{$database->name}'</h2>\n";
echo "<h2>Database '{$database->getName()}'</h2>\n";
echo "<ul>\n";
foreach ($database->getTables() as $table) {
echo '<li>', ($table->view ? 'view' : 'table') . " $table->name</li>\n";
echo '<li>', ($table->isView() ? 'view' : 'table') . " {$table->getName()}</li>\n";
}
echo "</ul>\n";
@@ -27,12 +27,12 @@ echo "</ul>\n";
// table reflection
$table = $database->getTable('products');
echo "<h2>Table '{$table->name}'</h2>\n";
echo "<h2>Table '{$table->getName()}'</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 "<li>{$column->getName()} <i>{$column->getNativeType()}</i> <code>{$column->getDefault()}</code></li>\n";
}
echo "</ul>\n";
@@ -40,9 +40,9 @@ echo "</ul>\n";
echo 'Indexes';
echo "<ul>\n";
foreach ($table->getIndexes() as $index) {
echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' (';
echo "<li>{$index->getName()} " . ($index->isPrimary() ? 'primary ' : '') . ($index->isUnique() ? 'unique' : '') . ' (';
foreach ($index->getColumns() as $column) {
echo "$column->name, ";
echo $column->getName(), ', ';
}
echo ")</li>\n";
}

View File

@@ -163,7 +163,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
if ($savepoint !== NULL) {
throw new DibiNotSupportedException('Savepoints are not supported in Firebird/Interbase.');
}
$this->transaction = ibase_trans($this->resource);
$this->transaction = ibase_trans($this->getResource());
$this->inTransaction = TRUE;
}

View File

@@ -459,7 +459,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
*/
public function getTables()
{
$version = pg_parameter_status($this->resource, 'server_version');
$version = pg_parameter_status($this->getResource(), 'server_version');
if ($version < 7.4) {
throw new DibiDriverException('Reflection requires PostgreSQL 7.4 and newer.');
}

View File

@@ -39,19 +39,19 @@ if ($config['driver'] !== 'sqlite3' && $config['driver'] !== 'pdo') {
$columns = $info->getColumns();
Assert::same('product_id', $columns[0]->name);
Assert::same('product_id', $columns[0]->getName());
if ($config['driver'] !== 'sqlite3' && $config['driver'] !== 'pdo') {
Assert::same('products', $columns[0]->tableName);
Assert::same('products', $columns[0]->getTableName());
}
Assert::null($columns[0]->getVendorInfo('xxx'));
if ($config['system'] !== 'sqlite') {
Assert::same('i', $columns[0]->type);
Assert::same('i', $columns[0]->getType());
}
Assert::null($columns[0]->nullable);
Assert::null($columns[0]->isNullable());
Assert::same('xxx', $columns[3]->name);
Assert::null($columns[3]->tableName);
Assert::same('xxx', $columns[3]->getName());
Assert::null($columns[3]->getTableName());
if ($config['system'] !== 'sqlite') {
Assert::same('i', $columns[0]->type);
Assert::same('i', $columns[0]->getType());
}
Assert::null($columns[3]->nullable);
Assert::null($columns[3]->isNullable());

View File

@@ -27,32 +27,32 @@ Assert::equal(['customers', 'orders', 'products'], $names);
Assert::false($meta->hasTable('xxxx'));
$table = $meta->getTable('products');
Assert::same('products', $table->name);
Assert::same('products', $table->getName());
Assert::false($table->isView());
Assert::same(2, count($table->getColumns()));
Assert::false($table->hasColumn('xxxx'));
Assert::true($table->hasColumn('product_id'));
Assert::true($table->hasColumn('Product_id'));
Assert::same('product_id', $table->getColumn('Product_id')->name);
Assert::same('product_id', $table->getColumn('Product_id')->getName());
$column = $table->getColumn('product_id');
Assert::same('product_id', $column->name);
Assert::same('products', $column->table->name);
Assert::same('i', $column->type);
Assert::type('string', $column->nativeType);
Assert::false($column->nullable);
Assert::true($column->autoIncrement);
Assert::same('product_id', $column->getName());
Assert::same('products', $column->getTable()->getName());
Assert::same('i', $column->getType());
Assert::type('string', $column->getNativeType());
Assert::false($column->isNullable());
Assert::true($column->isAutoIncrement());
$column = $table->getColumn('title');
Assert::same('title', $column->name);
Assert::same('products', $column->table->name);
Assert::same('s', $column->type);
Assert::type('string', $column->nativeType);
Assert::same(100, $column->size);
Assert::true($column->nullable);
Assert::false($column->autoIncrement);
//Assert::null($column->default);
Assert::same('title', $column->getName());
Assert::same('products', $column->getTable()->getName());
Assert::same('s', $column->getType());
Assert::type('string', $column->getNativeType());
Assert::same(100, $column->getSize());
Assert::true($column->isNullable());
Assert::false($column->isAutoIncrement());
//Assert::null($column->getDefault());
$indexes = $table->getIndexes();
@@ -60,16 +60,16 @@ $index = reset($indexes);
if ($config['system'] !== 'sqlite') {
Assert::same(2, count($indexes));
Assert::true($index->primary);
Assert::true($index->unique);
Assert::true($index->isPrimary());
Assert::true($index->isUnique());
Assert::same(1, count($index->getColumns()));
Assert::same('product_id', $index->columns[0]->name);
Assert::same('product_id', $index->getColumns()[0]->getName());
$index = next($indexes);
}
Assert::same('title', $index->name);
Assert::false($index->primary);
Assert::false($index->unique);
Assert::same('title', $index->getName());
Assert::false($index->isPrimary());
Assert::false($index->isUnique());
Assert::same(1, count($index->getColumns()));
Assert::same('title', $index->columns[0]->name);
Assert::same('title', $index->getColumns()[0]->getName());