mirror of
https://github.com/dg/dibi.git
synced 2025-08-13 17:44:11 +02:00
- DibiPostgreDriver: added support for "schema"
- DibiTable::fetch($conditions) (experimental) - DibiConnection no longer invokes autoloading
This commit is contained in:
@@ -74,10 +74,10 @@ class DibiConnection extends NObject
|
||||
|
||||
$driver = preg_replace('#[^a-z0-9_]#', '_', $config['driver']);
|
||||
$class = "Dibi" . $driver . "Driver";
|
||||
if (!class_exists($class)) {
|
||||
if (!class_exists($class, FALSE)) {
|
||||
include_once __FILE__ . "/../../drivers/$driver.php";
|
||||
|
||||
if (!class_exists($class)) {
|
||||
if (!class_exists($class, FALSE)) {
|
||||
throw new DibiException("Unable to create instance of dibi driver class '$class'.");
|
||||
}
|
||||
}
|
||||
|
@@ -225,14 +225,20 @@ abstract class DibiTable extends NObject
|
||||
|
||||
/**
|
||||
* Fetches single row.
|
||||
* @param scalar primary key value
|
||||
* @param scalar|array primary key value
|
||||
* @return array|object row
|
||||
*/
|
||||
public function fetch($what)
|
||||
public function fetch($conditions)
|
||||
{
|
||||
if (is_array($conditions)) {
|
||||
return $this->complete($this->connection->query(
|
||||
'SELECT * FROM %n', $this->name,
|
||||
'WHERE %and', $conditions
|
||||
))->fetch();
|
||||
}
|
||||
return $this->complete($this->connection->query(
|
||||
'SELECT * FROM %n', $this->name,
|
||||
'WHERE %n', $this->primary, '=' . $this->primaryModifier, $what
|
||||
'WHERE %n=' . $this->primaryModifier, $this->primary, $conditions
|
||||
))->fetch();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user