an other PostgreSQL compatibility problem: cast to varchar necessary

This commit is contained in:
Ralf Becker 2010-10-28 09:31:28 +00:00
parent 1e82a48e37
commit e30a515824

View File

@ -1251,7 +1251,7 @@ class egw_db
case 'mssql':
return "DATEDIFF(second,'1970-01-01',($expr))";
}
}
/**
@ -1313,6 +1313,38 @@ class egw_db
return false;
}
/**
* Cast a column or sql expression to integer, necessary at least for postgreSQL
*
* @param string $expr
* @return string
*/
function to_int($expr)
{
switch($this->Type)
{
case 'pgsql':
return $expr.'::integer';
}
return $expr;
}
/**
* Cast a column or sql expression to varchar, necessary at least for postgreSQL
*
* @param string $expr
* @return string
*/
function to_varchar($expr)
{
switch($this->Type)
{
case 'pgsql':
return 'CAST('.$expr.' AS varchar)';
}
return $expr;
}
/**
* Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements
*