$sql = <<
DELIMITER $
DROP PROCEDURE IF EXISTS `ss`$
CREATE DEFINER=`root`@`localhost` PROCEDURE `ss`()
BEGIN
IF NOT
EXISTS (SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'new' AND TABLE_NAME = 'n_test' AND COLUMN_NAME = 'age' )
THEN
ALTER TABLE n_test ADD COLUMN age INT(2) DEFAULT 0 COMMENT '年龄';
END IF;
END$
DELIMITER ;
sql;
if(M()->execute($sql)==0){
echo "执行成功";
}
//---------------------------------------------------------------------------==================================================================================
//thinkphp貌似不能直接调用存储过程,要用原生的方法。
//代码如下:
$conn=mysql_connect('10.21.2.191:3306','dmz','1124') or die("Sorry,can not connect to database");
$res = mysql_query("set names utf8", $conn);
mysql_select_db('dmz_act_basic_2016', $conn);
$userInfo_proc = "call proc_get_userinfo_details(".$data['userid'].",''); ";
//传了个参数
$res = mysql_query($userInfo_proc);//执行存储过程
$res = mysql_fetch_assoc($res);
?>