Other than Search and Replace, is there a way to add a prefix (phpay_item instead of item) to each table?
Since not all queries start with CAPITALS and not all references to each table is the same, this is a hard job to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In support area you'll find a modified db_func.inc.php for this cases.
This replaces all tables names in var $query with a RegularExpression to $prefix+tablename.
Or use following db_query()-function instead:
function db_query($query, $rp=1) {
global $db_type, $link, $stmt, $counter, $item, $f_row;
if ($rp == 1) {
$prefix="shopst_";
$tables = array("abt", "cart", "click", "color", "currency", "item", "itemgr",
"language", "link", "online", "package", "packinfo", "payment", "price", "pricetype", "shipment", "size",
"statistics", "user", "usrgroup");
foreach ($tables as $table) {
if (ereg("\ ".$table, $query)) {
if ($table!="user") $query=preg_replace("(".$table."(?!(ID|gr)))"," ".$prefix.$table, $query);
else $query=preg_replace("(".$table."(?!(ID|gr)))"," ".$prefix.$table, $query,1);
}
}
}
if ($rp==3) { echo "$query <br>\n"; }
if ($db_type == "mysql"){
return mysql_query($query);
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Other than Search and Replace, is there a way to add a prefix (phpay_item instead of item) to each table?
Since not all queries start with CAPITALS and not all references to each table is the same, this is a hard job to do.
In support area you'll find a modified db_func.inc.php for this cases.
This replaces all tables names in var $query with a RegularExpression to $prefix+tablename.
Or use following db_query()-function instead:
function db_query($query, $rp=1) {
global $db_type, $link, $stmt, $counter, $item, $f_row;
if ($rp == 1) {
$prefix="shopst_";
$tables = array("abt", "cart", "click", "color", "currency", "item", "itemgr",
"language", "link", "online", "package", "packinfo", "payment", "price", "pricetype", "shipment", "size",
"statistics", "user", "usrgroup");
foreach ($tables as $table) {
if (ereg("\ ".$table, $query)) {
if ($table!="user") $query=preg_replace("(".$table."(?!(ID|gr)))"," ".$prefix.$table, $query);
else $query=preg_replace("(".$table."(?!(ID|gr)))"," ".$prefix.$table, $query,1);
}
}
}
if ($rp==3) { echo "$query <br>\n"; }
if ($db_type == "mysql"){
return mysql_query($query);
}
}