Style fixes

This commit is contained in:
Bart Visscher 2013-08-07 18:16:34 +02:00
parent 95a959b10b
commit 2cc94cbc73
4 changed files with 8 additions and 6 deletions

View File

@ -249,7 +249,7 @@ class OC_DB {
static public function executeAudited( $stmt, array $parameters = null) { static public function executeAudited( $stmt, array $parameters = null) {
if (is_string($stmt)) { if (is_string($stmt)) {
// convert to an array with 'sql' // convert to an array with 'sql'
if (stripos($stmt,'LIMIT') !== false) { //OFFSET requires LIMIT, se we only neet to check for LIMIT if (stripos($stmt, 'LIMIT') !== false) { //OFFSET requires LIMIT, so we only need to check for LIMIT
// TODO try to convert LIMIT OFFSET notation to parameters, see fixLimitClauseForMSSQL // TODO try to convert LIMIT OFFSET notation to parameters, see fixLimitClauseForMSSQL
$message = 'LIMIT and OFFSET are forbidden for portability reasons,' $message = 'LIMIT and OFFSET are forbidden for portability reasons,'
. ' pass an array with \'limit\' and \'offset\' instead'; . ' pass an array with \'limit\' and \'offset\' instead';
@ -257,7 +257,7 @@ class OC_DB {
} }
$stmt = array('sql' => $stmt, 'limit' => null, 'offset' => null); $stmt = array('sql' => $stmt, 'limit' => null, 'offset' => null);
} }
if (is_array($stmt)){ if (is_array($stmt)) {
// convert to prepared statement // convert to prepared statement
if ( ! array_key_exists('sql', $stmt) ) { if ( ! array_key_exists('sql', $stmt) ) {
$message = 'statement array must at least contain key \'sql\''; $message = 'statement array must at least contain key \'sql\'';

View File

@ -18,10 +18,11 @@ class AdapterOCI8 extends Adapter {
return $this->conn->realLastInsertId($table); return $this->conn->realLastInsertId($table);
} }
const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
public function fixupStatement($statement) { public function fixupStatement($statement) {
$statement = str_replace( '`', '"', $statement ); $statement = str_replace( '`', '"', $statement );
$statement = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $statement ); $statement = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $statement );
$statement = str_ireplace( 'UNIX_TIMESTAMP()', "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400", $statement ); $statement = str_ireplace( 'UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement );
return $statement; return $statement;
} }
} }

View File

@ -14,9 +14,10 @@ class AdapterPgSql extends Adapter {
return $this->conn->fetchColumn('SELECT lastval()'); return $this->conn->fetchColumn('SELECT lastval()');
} }
const UNIX_TIMESTAMP_REPLACEMENT = 'cast(extract(epoch from current_timestamp) as integer)';
public function fixupStatement($statement) { public function fixupStatement($statement) {
$statement = str_replace( '`', '"', $statement ); $statement = str_replace( '`', '"', $statement );
$statement = str_ireplace( 'UNIX_TIMESTAMP()', 'cast(extract(epoch from current_timestamp) as integer)', $statement ); $statement = str_ireplace( 'UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement );
return $statement; return $statement;
} }
} }

View File

@ -53,7 +53,7 @@ class OC_DB_StatementWrapper {
*/ */
public function execute($input=array()) { public function execute($input=array()) {
if(OC_Config::getValue( "log_query", false)) { if(OC_Config::getValue( "log_query", false)) {
$params_str = str_replace("\n"," ",var_export($input,true)); $params_str = str_replace("\n", " ", var_export($input, true));
OC_Log::write('core', 'DB execute with arguments : '.$params_str, OC_Log::DEBUG); OC_Log::write('core', 'DB execute with arguments : '.$params_str, OC_Log::DEBUG);
} }
$this->lastArguments = $input; $this->lastArguments = $input;
@ -134,7 +134,7 @@ class OC_DB_StatementWrapper {
$host = OC_Config::getValue( "dbhost", "" ); $host = OC_Config::getValue( "dbhost", "" );
$user = OC_Config::getValue( "dbuser", "" ); $user = OC_Config::getValue( "dbuser", "" );
$pass = OC_Config::getValue( "dbpassword", "" ); $pass = OC_Config::getValue( "dbpassword", "" );
if (strpos($host,':')) { if (strpos($host, ':')) {
list($host, $port) = explode(':', $host, 2); list($host, $port) = explode(':', $host, 2);
} else { } else {
$port = false; $port = false;