Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [993] trunk/src/containers/mysql.class.php
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-03-08 16:55:09
|
Revision: 993 http://svn.sourceforge.net/phpfreechat/?rev=993&view=rev Author: kerphi Date: 2007-03-08 08:55:03 -0800 (Thu, 08 Mar 2007) Log Message: ----------- fix the 1672102 sourceforge bug Modified Paths: -------------- trunk/src/containers/mysql.class.php Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-03-08 14:53:41 UTC (rev 992) +++ trunk/src/containers/mysql.class.php 2007-03-08 16:55:03 UTC (rev 993) @@ -84,7 +84,7 @@ // advanced parameters (don't touch if you don't know what your are doing) $cfg["mysql_fieldtype_server"] = 'varchar(32)'; $cfg["mysql_fieldtype_group"] = 'varchar(64)'; - $cfg["mysql_fieldtype_subgroup"] = 'varchar(64)'; + $cfg["mysql_fieldtype_subgroup"] = 'varchar(128)'; $cfg["mysql_fieldtype_leaf"] = 'varchar(128)'; $cfg["mysql_fieldtype_leafvalue"] = 'text'; $cfg["mysql_fieldtype_timestamp"] = 'int(11)'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-08-06 13:12:25
|
Revision: 1085 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1085&view=rev Author: kerphi Date: 2007-08-06 06:12:26 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Optimize the setMeta method in the mysql container Modified Paths: -------------- trunk/src/containers/mysql.class.php Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-08-05 01:26:12 UTC (rev 1084) +++ trunk/src/containers/mysql.class.php 2007-08-06 13:12:26 UTC (rev 1085) @@ -165,12 +165,13 @@ if ($leafvalue == NULL){$leafvalue="";}; - $sql_select = "SELECT * FROM ".$c->container_cfg_mysql_table." WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf'"; + $sql_count = "SELECT COUNT(*) AS C FROM ".$c->container_cfg_mysql_table." WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf' LIMIT 1"; $sql_insert="REPLACE INTO ".$c->container_cfg_mysql_table." (`server`, `group`, `subgroup`, `leaf`, `leafvalue`, `timestamp`) VALUES('$server', '$group', '$subgroup', '$leaf', '".addslashes($leafvalue)."', '".time()."')"; $sql_update="UPDATE ".$c->container_cfg_mysql_table." SET `leafvalue`='".addslashes($leafvalue)."', `timestamp`='".time()."' WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf'"; - - $res = mysql_query($sql_select, $db); - if( !(mysql_num_rows($res)>0) ) + + $res = mysql_query($sql_count, $db); + $row = mysql_fetch_array($res, MYSQL_ASSOC); + if( $row['C'] == 0 ) { if ($c->debug) file_put_contents("/tmp/debug.txt", "\nsetSQL(".$sql_insert.")", FILE_APPEND | LOCK_EX); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-08-06 14:52:28
|
Revision: 1088 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1088&view=rev Author: kerphi Date: 2007-08-06 07:52:30 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Oups the mysql table should not be hardcoded. Modified Paths: -------------- trunk/src/containers/mysql.class.php Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-08-06 14:44:57 UTC (rev 1087) +++ trunk/src/containers/mysql.class.php 2007-08-06 14:52:30 UTC (rev 1088) @@ -276,7 +276,7 @@ $time = time(); // search for the existing leafvalue - mysql_query('LOCK TABLES phpfreechat WRITE;', $db); + mysql_query('LOCK TABLES '.$c->container_cfg_mysql_table.' WRITE;', $db); $sql_select = "SELECT leafvalue FROM ".$c->container_cfg_mysql_table." WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf' LIMIT 1"; $res = mysql_query($sql_select, $db); $row = mysql_fetch_array($res, MYSQL_ASSOC); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-08-06 15:19:58
|
Revision: 1090 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1090&view=rev Author: kerphi Date: 2007-08-06 08:19:59 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Optimize the mysql inMeta method by using the mysql LAST_INSERT_ID command ( see http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html ) Modified Paths: -------------- trunk/src/containers/mysql.class.php Modified: trunk/src/containers/mysql.class.php =================================================================== --- trunk/src/containers/mysql.class.php 2007-08-06 15:18:53 UTC (rev 1089) +++ trunk/src/containers/mysql.class.php 2007-08-06 15:19:59 UTC (rev 1090) @@ -276,11 +276,10 @@ $time = time(); // search for the existing leafvalue - mysql_query('LOCK TABLES '.$c->container_cfg_mysql_table.' WRITE;', $db); - $sql_select = "SELECT leafvalue FROM ".$c->container_cfg_mysql_table." WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf' LIMIT 1"; - $res = mysql_query($sql_select, $db); + $sql_count = "SELECT COUNT(*) AS C FROM ".$c->container_cfg_mysql_table." WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf' LIMIT 1"; + $res = mysql_query($sql_count, $db); $row = mysql_fetch_array($res, MYSQL_ASSOC); - if( !isset($row['leafvalue']) ) + if( $row['C'] == 0 ) { if ($c->debug) file_put_contents("/tmp/debug.txt", "\nsetSQL(".$sql_insert.")", FILE_APPEND | LOCK_EX); @@ -292,11 +291,12 @@ { if ($c->debug) file_put_contents("/tmp/debug.txt", "\nsetSQL(".$sql_update.")", FILE_APPEND | LOCK_EX); - $leafvalue = $row['leafvalue'] + 1; - $sql_update="UPDATE ".$c->container_cfg_mysql_table." SET `leafvalue`='".$leafvalue."', `timestamp`='".$time."' WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf'"; + $sql_update="UPDATE ".$c->container_cfg_mysql_table." SET `leafvalue`= LAST_INSERT_ID( leafvalue + 1 ), `timestamp`='".$time."' WHERE `server`='$server' AND `group`='$group' AND `subgroup`='$subgroup' AND `leaf`='$leaf'"; mysql_query($sql_update, $db); + $res = mysql_query('SELECT LAST_INSERT_ID();', $db); + $row = mysql_fetch_array($res, MYSQL_ASSOC); + $leafvalue = $row['LAST_INSERT_ID()']; } - mysql_query('UNLOCK TABLES;', $db); $ret["value"][] = $leafvalue; $ret["timestamp"][] = $time; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |