diff --git a/xhprof_lib/utils/Db/Mysql.php b/xhprof_lib/utils/Db/Mysql.php index 249c16c8..d1e5a421 100644 --- a/xhprof_lib/utils/Db/Mysql.php +++ b/xhprof_lib/utils/Db/Mysql.php @@ -1,34 +1,34 @@ prefix - * - * - CREATE TABLE `details` ( - `id` char(17) NOT NULL, - `url` varchar(255) default NULL, - `c_url` varchar(255) default NULL, - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `server name` varchar(64) default NULL, - `perfdata` MEDIUMBLOB, - `type` tinyint(4) default NULL, - `cookie` BLOB, - `post` BLOB, - `get` BLOB, - `pmu` int(11) unsigned default NULL, - `wt` int(11) unsigned default NULL, - `cpu` int(11) unsigned default NULL, - `server_id` char(3) NOT NULL default 't11', - `aggregateCalls_include` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `url` (`url`), - KEY `c_url` (`c_url`), - KEY `cpu` (`cpu`), - KEY `wt` (`wt`), - KEY `pmu` (`pmu`), - KEY `timestamp` (`timestamp`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8; - +/** + * When setting the `id` column, consider the length of the prefix you're specifying in $this->prefix + * + * + CREATE TABLE `details` ( + `id` char(17) NOT NULL, + `url` varchar(255) default NULL, + `c_url` varchar(255) default NULL, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `server name` varchar(64) default NULL, + `perfdata` MEDIUMBLOB, + `type` tinyint(4) default NULL, + `cookie` BLOB, + `post` BLOB, + `get` BLOB, + `pmu` int(11) unsigned default NULL, + `wt` int(11) unsigned default NULL, + `cpu` int(11) unsigned default NULL, + `server_id` char(3) NOT NULL default 't11', + `aggregateCalls_include` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `url` (`url`), + KEY `c_url` (`c_url`), + KEY `cpu` (`cpu`), + KEY `wt` (`wt`), + KEY `pmu` (`pmu`), + KEY `timestamp` (`timestamp`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + */ require_once XHPROF_LIB_ROOT.'/utils/Db/Abstract.php'; @@ -37,17 +37,17 @@ class Db_Mysql extends Db_Abstract public function connect() { - $this->linkID = mysql_connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']); - if ($this->linkID === FALSE) - { - xhprof_error("Could not connect to db"); - throw new Exception("Unable to connect to database"); - return false; - } - $this->query("SET NAMES utf8"); - mysql_select_db($this->config['dbname'], $this->linkID); + $this->linkID = mysql_connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']); + if ($this->linkID === FALSE) + { + xhprof_error("Could not connect to db"); + throw new Exception("Unable to connect to database"); + return false; + } + $this->query("SET NAMES utf8"); + mysql_select_db($this->config['dbname'], $this->linkID); } - + public function query($sql) { return mysql_query($sql, $this->linkID); @@ -68,13 +68,13 @@ public function affectedRows() return mysql_affected_rows($this->linkID); } - public static function unixTimestamp($field) - { - return 'UNIX_TIMESTAMP('.$field.')'; + public static function unixTimestamp($field) + { + return 'UNIX_TIMESTAMP('.$field.')'; } - public static function dateSub($days) - { - return 'DATE_SUB(CURDATE(), INTERVAL '.$days.' DAY)'; + public static function dateSub($days) + { + return 'DATE_SUB(CURDATE(), INTERVAL '.$days.' DAY)'; } }