1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 01:24:06 +02:00

- added dibi::setSubstFallBack()

- added DibiFluent::fetch()
This commit is contained in:
David Grudl
2008-06-08 12:44:44 +00:00
parent c23bf15a3d
commit 4e41f1641e
4 changed files with 93 additions and 10 deletions

View File

@@ -27,7 +27,7 @@
* @package dibi
* @version $Revision$ $Date$
*/
final class DibiFluent extends /*Nette::*/Object
class DibiFluent extends /*Nette::*/Object
{
/** @var array */
public static $masks = array(
@@ -103,6 +103,7 @@ final class DibiFluent extends /*Nette::*/Object
// special types or argument
if (count($args) === 1) {
$arg = $args[0];
// TODO: really ignore TRUE?
if ($arg === TRUE) {
$args = array();
@@ -115,6 +116,7 @@ final class DibiFluent extends /*Nette::*/Object
// append to clause
$this->cursor = & $this->clauses[$clause];
// TODO: really delete?
if ($args === array(FALSE)) {
$this->cursor = NULL;
return $this;
@@ -224,6 +226,21 @@ final class DibiFluent extends /*Nette::*/Object
/**
* Generates, executes SQL query and fetches the single row.
* @return array|FALSE array on success, FALSE if no next record
* @throws DibiException
*/
public function fetch()
{
if ($this->command === 'SELECT') {
$this->clauses['LIMIT'] = array(1);
}
return $this->connection->query($this->_export())->fetch();
}
/**
* Generates and prints SQL query or it's part.
* @param string clause name

View File

@@ -450,10 +450,7 @@ final class DibiTranslator extends /*Nette::*/Object
*/
private function delimite($value)
{
if (strpos($value, ':') !== FALSE) {
$value = strtr($value, dibi::getSubst());
}
return $this->driver->escape($value, dibi::IDENTIFIER);
return $this->driver->escape(dibi::substitute($value), dibi::IDENTIFIER);
}