Add compress flag when connecting with mysql

This commit is contained in:
Michael RICOIS 2012-05-22 06:18:19 +00:00
parent 406dff7629
commit ab819c5c6e

View File

@ -1,7 +1,7 @@
<?php <?php
class WDB { class WDB {
private $host; private $host;
private $database; private $database;
private $user; private $user;
@ -10,7 +10,7 @@ class WDB {
private $result; private $result;
public function __construct($database='', $host='', $user='', $password='') { public function __construct($database='', $host='', $user='', $password='') {
if ($host=='') $this->host=MYSQL_HOST; if ($host=='') $this->host=MYSQL_HOST;
else $this->host=$host; else $this->host=$host;
if ($user=='') $this->user=MYSQL_USER; if ($user=='') $this->user=MYSQL_USER;
@ -19,11 +19,14 @@ class WDB {
else $this->password=$password; else $this->password=$password;
if ($database=='') $this->database=MYSQL_DEFAULT_DB; if ($database=='') $this->database=MYSQL_DEFAULT_DB;
else $this->database=$database; else $this->database=$database;
//if (defined(MYSQL_PORT)) $this->host = $this->host.':'.MYSQL_PORT; //if (defined(MYSQL_PORT)) $this->host = $this->host.':'.MYSQL_PORT;
$this->host = $this->host.':53336'; $this->host = $this->host.':53336';
$this->con_id = mysql_connect($this->host, $this->user, $this->password); //Server is far away try to compress data
$flags = MYSQL_CLIENT_COMPRESS;
$this->con_id = mysql_connect($this->host, $this->user, $this->password, false, $flags);
if (!($this->con_id === false)) { if (!($this->con_id === false)) {
if (mysql_select_db($this->database, $this->con_id) === false) { if (mysql_select_db($this->database, $this->con_id) === false) {
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL; echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
@ -56,7 +59,7 @@ public function insert($table, $toAdd, $debug=false, $low_priority=false){
$values = "'".implode(array_values($tmp), "','")."'"; # better $values = "'".implode(array_values($tmp), "','")."'"; # better
$values = str_replace("'NULL'", 'NULL', $values); $values = str_replace("'NULL'", 'NULL', $values);
if ($low_priority) if ($low_priority)
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');'; $query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
else else