Change spaces to tabs

This commit is contained in:
slawkens 2024-11-19 07:03:06 +01:00
parent 8ae22accc9
commit 1e6892971b

View File

@ -53,49 +53,49 @@ class OTS_DB_MySQL extends OTS_Base_DB
* @param array $params Connection parameters. * @param array $params Connection parameters.
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
*/ */
public function __construct($params) public function __construct($params)
{ {
$user = null; $user = null;
$password = null; $password = null;
$dns = array(); $dns = array();
// host:port support // host:port support
if( strpos(':', $params['host']) !== false) if( strpos(':', $params['host']) !== false)
{ {
$host = explode(':', $params['host'], 2); $host = explode(':', $params['host'], 2);
$params['host'] = $host[0]; $params['host'] = $host[0];
$params['port'] = $host[1]; $params['port'] = $host[1];
} }
if( isset($params['database']) ) if( isset($params['database']) )
{ {
$dns[] = 'dbname=' . $params['database']; $dns[] = 'dbname=' . $params['database'];
} }
if( isset($params['user']) ) if( isset($params['user']) )
{ {
$user = $params['user']; $user = $params['user'];
} }
if( isset($params['password']) ) if( isset($params['password']) )
{ {
$password = $params['password']; $password = $params['password'];
} }
if( isset($params['prefix']) ) if( isset($params['prefix']) )
{ {
$this->prefix = $params['prefix']; $this->prefix = $params['prefix'];
} }
if( isset($params['log']) && $params['log'] ) if( isset($params['log']) && $params['log'] )
{ {
$this->logged = true; $this->logged = true;
} }
if( !isset($params['persistent']) ) { if( !isset($params['persistent']) ) {
$params['persistent'] = false; $params['persistent'] = false;
} }
global $config; global $config;
$cache = Cache::getInstance(); $cache = Cache::getInstance();
@ -144,10 +144,10 @@ class OTS_DB_MySQL extends OTS_Base_DB
} }
parent::__construct('mysql:' . implode(';', $dns), $user, $password, $driverAttributes); parent::__construct('mysql:' . implode(';', $dns), $user, $password, $driverAttributes);
} }
public function __destruct() public function __destruct()
{ {
global $config; global $config;
$cache = Cache::getInstance(); $cache = Cache::getInstance();
@ -176,10 +176,10 @@ class OTS_DB_MySQL extends OTS_Base_DB
* @param string $name Field name. * @param string $name Field name.
* @return string Quoted name. * @return string Quoted name.
*/ */
public function fieldName($name) public function fieldName($name)
{ {
return '`' . $name . '`'; return '`' . $name . '`';
} }
/** /**
* LIMIT/OFFSET clause for queries. * LIMIT/OFFSET clause for queries.
@ -188,26 +188,26 @@ class OTS_DB_MySQL extends OTS_Base_DB
* @param int|bool $offset Number of rows to be skipped before applying query effects (false if no offset). * @param int|bool $offset Number of rows to be skipped before applying query effects (false if no offset).
* @return string LIMIT/OFFSET SQL clause for query. * @return string LIMIT/OFFSET SQL clause for query.
*/ */
public function limit($limit = false, $offset = false) public function limit($limit = false, $offset = false)
{ {
// by default this is empty part // by default this is empty part
$sql = ''; $sql = '';
if($limit !== false) if($limit !== false)
{ {
$sql = ' LIMIT '; $sql = ' LIMIT ';
// OFFSET has no effect if there is no LIMIT // OFFSET has no effect if there is no LIMIT
if($offset !== false) if($offset !== false)
{ {
$sql .= $offset . ', '; $sql .= $offset . ', ';
} }
$sql .= $limit; $sql .= $limit;
} }
return $sql; return $sql;
} }
public function hasTable($name) { public function hasTable($name) {
if(isset($this->has_table_cache[$name])) { if(isset($this->has_table_cache[$name])) {