}
/**
* Try a connection to the database
*
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @param string $db Database name
* @param bool $new_db_link
* @param string|bool $engine
* @param int $timeout
* @return int Error code or 0 if connection was successful
*/
public static function checkConnection($server, $user, $pwd, $db, $new_db_link = true, $engine = null, $timeout = 5)
{
return call_user_func_array(array(Db::getClass(), 'tryToConnect'), array($server, $user, $pwd, $db, $new_db_link, $engine, $timeout));
}
/**
* Try a connection to the database and set names to UTF-8
*
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @return bool
*/
public static function checkEncoding($server, $user, $pwd)
{
return call_user_func_array(array(Db::getClass(), 'tryUTF8'), array($server, $user, $pwd));
}
/**
* Try a connection to the database and check if at least one table with same prefix exists
*
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @param string $db Database name
* @param string $prefix Tables prefix
* @return bool
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
}
/**
* Tries to connect to the database and create a table (checking creation privileges)
*
* @param string $server
* @param string $user
* @param string $pwd
* @param string $db
* @param string $prefix
* @param string|null $engine Table engine
* @return bool|string True, false or error
*/
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
}
/**
* Checks if auto increment value and offset is 1
*
* @param string $server
* @param string $user
* @param string $pwd
* @return bool
*/
public static function checkAutoIncrement($server, $user, $pwd)
{
return call_user_func_array(array(Db::getClass(), 'checkAutoIncrement'), array($server, $user, $pwd));
}
/**
* Executes a query
*
* @deprecated 1.5.0.1
* @param string|DbQuery $sql
* @param bool $use_cache
* @return array|bool|mysqli_result|PDOStatement|resource
* @throws PrestaShopDatabaseException
*/
public static function s($sql, $use_cache = true)
{
Tools::displayAsDeprecated();
return Db::getInstance()->executeS($sql, true, $use_cache);
}
/**
* Executes a query
*
* @deprecated 1.5.0.1
* @param $sql
* @param int $use_cache
* @return array|bool|mysqli_result|PDOStatement|resource
*/
public static function ps($sql, $use_cache = 1)
{
Tools::displayAsDeprecated();
$ret = Db::s($sql, $use_cache);
return $ret;
}
/**
* Executes a query and kills process (dies)
*
* @deprecated 1.5.0.1
* @param $sql
* @param int $use_cache
*/
public static function ds($sql, $use_cache = 1)
{
Tools::displayAsDeprecated();
Db::s($sql, $use_cache);
die();
}
/**
* Get used link instance
*
* @return PDO|mysqli|resource Resource
*/
public function getLink()
{
return $this->link;
}
}