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:
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user