1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-12 17:14:16 +02:00

prefix & substitution support (0.6c)

This commit is contained in:
David Grudl
2006-08-25 15:17:40 +00:00
parent 82e82e8872
commit 2cc9fa22fb
13 changed files with 450 additions and 319 deletions

View File

@@ -34,6 +34,13 @@ abstract class DibiDriver
protected
$config;
/**
* Substitutions for identifiers
* @var array
*/
protected
$substs = array();
/**
* Describes how convert some datatypes to SQL command
* @var array
@@ -153,6 +160,45 @@ abstract class DibiDriver
/**
* Create a new substitution pair for indentifiers
* @param string from
* @param string to
* @return void
*/
public function addSubst($expr, $subst)
{
$this->substs[':'.$expr.':'] = $subst;
}
/**
* Remove substitution pair
* @param string from
* @return void
*/
public function removeSubst($expr)
{
unset($this->substs[':'.$expr.':']);
}
/**
* Apply substitutions to indentifier
* @param string indentifier
* @return string
*/
protected function applySubsts($value)
{
// apply substitutions
if ($this->substs && (strpos($value, ':') !== FALSE))
return strtr($value, $this->substs);
return $value;
}
} // class DibiDriver