php怎么创建mysql触发器??? 我现在有很多个触发器,做了一个php的安装程序,但是到创建数据库的那一步才发现不能用mysql_query()来创建触发器不知道怎么做,是php的函数mysql_query不能创建还是要依靠其他的技术 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function updateTrigger($usercnt){ global $config; $conn=mysql_connect("{$config['db']['host']}:{$config['db']['port']}" ,$config['db']['username'],$config['db']['password']) or die('Error'); mysql_query('set names utf8', $conn); $sql = "DROP TRIGGER weibo_work_division_trigger;"; $result = mysql_db_query($config['db']['dbname'], $sql, $conn); $sql = " CREATE TRIGGER `weibo_work_division_trigger` BEFORE INSERT ON `weibo` FOR EACH ROW set new.special_flag2 = "; if($usercnt["1100_cnt"]){ $sql .= "if(new.city_code = 1100, floor(rand() * {$usercnt["1100_cnt"]}) + 110000,"; } if($usercnt["3100_cnt"]){ $sql .= "if(new.city_code = 3100, floor(rand() * {$usercnt["3100_cnt"]}) + 310000,"; } if($usercnt["3205_cnt"]){ $sql .= "if(new.city_code = 3205, floor(rand() * {$usercnt["3205_cnt"]}) + 320500,"; } $usercnt["0_cnt"] = max($usercnt["0_cnt"],20);//最少按照20人分配,防止管理员添加用户过程太长导致数据堆积在小号中 $sql .= "floor(rand() * {$usercnt["0_cnt"]})"; if($usercnt["1100_cnt"]){ $sql .= ")"; } if($usercnt["3100_cnt"]){ $sql .= ")"; } if($usercnt["3205_cnt"]){ $sql .= ")"; } $sql .= ";"; $return = mysql_db_query($config['db']['dbname'], $sql, $conn); return $return;} PHP对PHP文件权限的控制是在哪里? asXML()使用问题 求这样的一个函数,自己经验不足实在写不出来请大家帮忙 php会缓存include的文件吗? jqgrid显示不了数据 我的服务器用FTP上传东西时可以写入,为什么用PHP使用$_FILE文件就传不上去. 高分求一段组合查询的代码..... 一个小问题 急!急!急! 用php如何读取excel文档 请教一个问题 谢谢 新手求助!查询语句 ss
{
global $config;
$conn=mysql_connect("{$config['db']['host']}:{$config['db']['port']}" ,$config['db']['username'],$config['db']['password']) or die('Error');
mysql_query('set names utf8', $conn);
$sql = "DROP TRIGGER weibo_work_division_trigger;";
$result = mysql_db_query($config['db']['dbname'], $sql, $conn);
$sql = " CREATE TRIGGER `weibo_work_division_trigger` BEFORE INSERT ON `weibo` FOR EACH ROW set new.special_flag2 = ";
if($usercnt["1100_cnt"]){
$sql .= "if(new.city_code = 1100, floor(rand() * {$usercnt["1100_cnt"]}) + 110000,";
}
if($usercnt["3100_cnt"]){
$sql .= "if(new.city_code = 3100, floor(rand() * {$usercnt["3100_cnt"]}) + 310000,";
}
if($usercnt["3205_cnt"]){
$sql .= "if(new.city_code = 3205, floor(rand() * {$usercnt["3205_cnt"]}) + 320500,";
}
$usercnt["0_cnt"] = max($usercnt["0_cnt"],20);//最少按照20人分配,防止管理员添加用户过程太长导致数据堆积在小号中
$sql .= "floor(rand() * {$usercnt["0_cnt"]})";
if($usercnt["1100_cnt"]){
$sql .= ")";
}
if($usercnt["3100_cnt"]){
$sql .= ")";
}
if($usercnt["3205_cnt"]){
$sql .= ")";
}
$sql .= ";";
$return = mysql_db_query($config['db']['dbname'], $sql, $conn);
return $return;
}