两个函数:
① source/function_common.php----->inserttable()
function inserttable($tablename, $insertsqlarr, $returnid=0, $replace = false, $silent=0) {
global $_SGLOBAL;
$insertkeysql = $insertvaluesql = $comma = '';
foreach ($insertsqlarr as $insert_key => $insert_value) {
$insertkeysql .= $comma.'`'.$insert_key.'`';
$insertvaluesql .= $comma.'\''.$insert_value.'\'';
$comma = ', ';
}//$comma这个定义真牛鼻
$method = $replace?'REPLACE':'INSERT';
$_SGLOBAL['db']->query($method.' INTO '.tname($tablename).' ('.$insertkeysql.') VALUES ('.$insertvaluesql.')', $silent?'SILENT':'');
if($returnid && !$replace) {
return $_SGLOBAL['db']->insert_id();
}
}
②同一个文件下tname();
function tname($name) {
global $_SC;
return $_SC['tablepre'].$name;//将得到的表的名字加上前缀,哇靠
}