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.ini的safe_mode探讨! discuz1.5在ie下,用回车时,换不了行的问题,在线等 这句php运行怎么出错了? PHP xajax 读取数据后再另一个框架如何显示出来? 求助:php内建类的资料 剖析方法求救 MSN一样的消息提示??加链接不好使 求救: 请各位师兄赐教:asp与php之间的转换问题 新手求助!查询语句 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;
}