Update of /cvsroot/basedb/basedb/www In directory usw-pr-cvs1:/tmp/cvs-serv19503 Modified Files: bioassay.inc.php bioassayset.inc.php common.inc.php experiment.inc.php mysql.inc.php pgsql.inc.php plot.inc.php Log Message: Turned dynamic database into table name prefix Index: bioassay.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bioassay.inc.php,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** bioassay.inc.php 9 Sep 2002 06:29:34 -0000 1.33 --- bioassay.inc.php 9 Sep 2002 10:56:08 -0000 1.34 *************** *** 75,79 **** return false; ! $query = "DELETE FROM $config[dbDynamic].BioAssayData$this->experiment ". "WHERE `bioAssay` = $this->id"; query($query); --- 75,79 ---- return false; ! $query = "DELETE FROM $config[dbDynamic]BioAssayData$this->experiment ". "WHERE `bioAssay` = $this->id"; [...197 lines suppressed...] "SELECT $this->id, position, molecule, $i1, $i2, ($i1) / ($i2) ". --- 942,946 ---- } ! $query = "INSERT INTO $config[dbDynamic]BioAssayData$this->experiment ". "(`bioAssay`, position, molecule, intensity1, intensity2, ratio) ". "SELECT $this->id, position, molecule, $i1, $i2, ($i1) / ($i2) ". *************** *** 1053,1057 **** $query = "SELECT $xc AS `A`, $yc AS `B`, $extra ". ! "FROM $config[dbDynamic].BioAssayData$this->experiment bad ". $sea->getExtraTables()." ". "WHERE bad.`bioAssay` = $this->id ".$sea->getExtraWhere()." ". --- 1053,1057 ---- $query = "SELECT $xc AS `A`, $yc AS `B`, $extra ". ! "FROM $config[dbDynamic]BioAssayData$this->experiment bad ". $sea->getExtraTables()." ". "WHERE bad.`bioAssay` = $this->id ".$sea->getExtraWhere()." ". Index: bioassayset.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/bioassayset.inc.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** bioassayset.inc.php 8 Sep 2002 22:38:08 -0000 1.25 --- bioassayset.inc.php 9 Sep 2002 10:56:08 -0000 1.26 *************** *** 96,103 **** $query = "DELETE FROM BioAssaySetCreation WHERE `bioAssaySet` = $id"; query($query); ! $query = "DELETE FROM $config[dbDynamic].BioAssaySetGene$expid ". "WHERE `bioAssaySet` = $id"; query($query); ! $query = "DELETE FROM $config[dbDynamic].BioAssaySetPosGene$expid ". "WHERE `bioAssaySet` = $id"; query($query); --- 96,103 ---- $query = "DELETE FROM BioAssaySetCreation WHERE `bioAssaySet` = $id"; [...222 lines suppressed...] "SELECT STRAIGHT_JOIN $this->id, bad.position, bad.molecule, COUNT(*) ". --- 641,645 ---- // appear in. $query = "INSERT INTO ". ! "$config[dbDynamic]BioAssaySetPosGene$this->experiment ". "(`bioAssaySet`, position, molecule, cnt) ". "SELECT STRAIGHT_JOIN $this->id, bad.position, bad.molecule, COUNT(*) ". *************** *** 678,682 **** { global $config; ! $table = "$config[dbDynamic].BioAssayData$this->experiment"; $columns = array("bioAssay", "position", "molecule", "intensity1", "intensity2", "ratio"); --- 680,684 ---- { global $config; ! $table = "$config[dbDynamic]BioAssayData$this->experiment"; $columns = array("bioAssay", "position", "molecule", "intensity1", "intensity2", "ratio"); Index: common.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/common.inc.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** common.inc.php 8 Sep 2002 13:18:33 -0000 1.18 --- common.inc.php 9 Sep 2002 10:56:08 -0000 1.19 *************** *** 26,29 **** --- 26,30 ---- require_once("display.inc.php"); require_once("getconfig.inc.php"); + require_once("db.inc.php"); if(!isset($config) || !is_array($config)) *************** *** 49,52 **** --- 50,57 ---- unset($cfgvars); unset($v); + + // The name of the dynamic database has to be turned into something + // that can be put in an SQL statement as the prefix of a table name. + db_dynamic_db_prepare($config["dbDynamic"]); // This appeared before we had chosen the name 'BASE'. It used to be in Index: experiment.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/experiment.inc.php,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** experiment.inc.php 9 Sep 2002 06:33:50 -0000 1.48 --- experiment.inc.php 9 Sep 2002 10:56:08 -0000 1.49 *************** *** 88,96 **** { if(!db_table_copy("TemplateBioAssayData", ! "$config[dbDynamic].BioAssayData$this->id") || !db_table_copy("TemplateBioAssaySetGene", ! "$config[dbDynamic].BioAssaySetGene$this->id") || !db_table_copy("TemplateBioAssaySetPosGene", ! "$config[dbDynamic].BioAssaySetPosGene$this->id")) { if(!$this->remove()) --- 88,96 ---- { if(!db_table_copy("TemplateBioAssayData", ! "$config[dbDynamic]BioAssayData$this->id") || !db_table_copy("TemplateBioAssaySetGene", ! "$config[dbDynamic]BioAssaySetGene$this->id") || !db_table_copy("TemplateBioAssaySetPosGene", ! "$config[dbDynamic]BioAssaySetPosGene$this->id")) { if(!$this->remove()) *************** *** 114,120 **** return false; ! db_table_drop("$config[dbDynamic].BioAssayData$id"); ! db_table_drop("$config[dbDynamic].BioAssaySetGene$id"); ! db_table_drop("$config[dbDynamic].BioAssaySetPosGene$id"); return true; } --- 114,120 ---- return false; ! db_table_drop("$config[dbDynamic]BioAssayData$id"); ! db_table_drop("$config[dbDynamic]BioAssaySetGene$id"); ! db_table_drop("$config[dbDynamic]BioAssaySetPosGene$id"); return true; } Index: mysql.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/mysql.inc.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mysql.inc.php 9 Sep 2002 06:39:01 -0000 1.11 --- mysql.inc.php 9 Sep 2002 10:56:08 -0000 1.12 *************** *** 275,277 **** --- 275,284 ---- } + function db_dynamic_db_prepare(&$dyn) + { + // MySQL can access a table in another database as database.table, + // so we just append a '.' to the database name. + $dyn .= "."; + } + ?> Index: pgsql.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/pgsql.inc.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pgsql.inc.php 9 Sep 2002 06:39:01 -0000 1.7 --- pgsql.inc.php 9 Sep 2002 10:56:08 -0000 1.8 *************** *** 339,341 **** --- 339,353 ---- } + function db_dynamic_db_prepare(&$dyn) + { + // PostgreSQL can only access tables in one database at a time, + // so we turn this into a prefix for the table name. As there's + // (by default) a 31-character limit on table names, we need to + // make sure that the name doesn't get to long. The longest table + // name we can expect is BioAssaySetPosGene[0-9]{10}, which has + // 28 characters. Although having 10^9 Experiments seems a bit odd, + // we play it safe and limit the prefix to 2 chars plus underscore. + $dyn = substr($dyn, 0, 2)."_"; + } + ?> Index: plot.inc.php =================================================================== RCS file: /cvsroot/basedb/basedb/www/plot.inc.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** plot.inc.php 8 Sep 2002 22:38:08 -0000 1.20 --- plot.inc.php 9 Sep 2002 10:56:08 -0000 1.21 *************** *** 435,439 **** if($a1->type == "v") ! $table1 = "$config[dbDynamic].BioAssayData".$a1->vset->getExperiment()." t1"; else $table1 = "RawBioAssayData t1"; if($a1->type == $a2->type && $a1->id == $a2->id) --- 435,439 ---- if($a1->type == "v") ! $table1 = "$config[dbDynamic]BioAssayData".$a1->vset->getExperiment()." t1"; else $table1 = "RawBioAssayData t1"; if($a1->type == $a2->type && $a1->id == $a2->id) *************** *** 465,469 **** { if($a2->type == "v") ! $table2 = "$config[dbDynamic].BioAssayData".$a2->vset->getExperiment()." t2"; else $table2 = "RawBioAssayData t2"; --- 465,469 ---- { if($a2->type == "v") ! $table2 = "$config[dbDynamic]BioAssayData".$a2->vset->getExperiment()." t2"; else $table2 = "RawBioAssayData t2"; |