src/Database/Drivers/LegacyDriver.php
/**
	 * Connects to the database server.
	 *
	 * @throws DatabaseDriverException on error
	 */
Connects to the database server.
@throws DatabaseDriverException on error
Connects to the database server . @throws DatabaseDriverException on error
public function connect() {
		if ($this->connected) {
			return;
		}
		Profiler::start('database:connect', 'mysql');
		$config = $this->database->getConfig();
		$port = isset($config['port']) ? $config['port'] : 3306;
		$host = $config['host'] . ':' . $port;
		$handle = @mysql_connect($host, $config['username'], $config['password']);
		if (!$handle) {
			throw new DatabaseDriverException(sprintf('Failed to connect to database: %s', mysql_error($this->handle)), mysql_errno($this->handle));
		}
		if (!@mysql_select_db($config['database'], $handle)) {
			throw new DatabaseDriverException(
				sprintf('Failed to connect to database: Unknown database \'%s\' or no permissions',
				$config['database'])
			);
		}
		$this->handle = $handle;
		$this->connected = true;
		@mysql_set_charset($config['charset'], $this->handle);
		@mysql_query(sprintf('SET NAMES %s COLLATE %s;', $config['charset'], $config['collation']), $this->handle);
		if (config('database.send_timezone', true)) {
			$this->database->setTimezone();
		}
		Profiler::stop('database:connect');
	}
public function connect ( ) { if ( $ this -> connected ) { return ; } Profiler :: start ( 'database:connect' , 'mysql' ) ; $ config = $ this -> database -> getConfig ( ) ; $ port = isset ( $ config [ 'port' ] ) ? $ config [ 'port' ] : 3306 ; $ host = $ config [ 'host' ] . ':' . $ port ; $ handle = @ mysql_connect ( $ host , $ config [ 'username' ] , $ config [ 'password' ] ) ; if ( ! $ handle ) { throw new DatabaseDriverException ( sprintf ( 'Failed to connect to database: %s' , mysql_error ( $ this -> handle ) ) , mysql_errno ( $ this -> handle ) ) ; } if ( ! @ mysql_select_db ( $ config [ 'database' ] , $ handle ) ) { throw new DatabaseDriverException ( sprintf ( 'Failed to connect to database: Unknown database \'%s\' or no permissions' , $ config [ 'database' ] ) ) ; } $ this -> handle = $ handle ; $ this -> connected = true ; @ mysql_set_charset ( $ config [ 'charset' ] , $ this -> handle ) ; @ mysql_query ( sprintf ( 'SET NAMES %s COLLATE %s;' , $ config [ 'charset' ] , $ config [ 'collation' ] ) , $ this -> handle ) ; if ( config ( 'database.send_timezone' , true ) ) { $ this -> database -> setTimezone ( ) ; } Profiler :: stop ( 'database:connect' ) ; }
Connects to the database server.
Connects to the database server .
// Save the handle and status // Set the charset and collation