//$value=array('test'=>'中文字符串',"中文字符串",121312,'test',mt_rand(1,9999)); //$value=json_encode($value); //var_dump($value); //$sql = "update user_1 set `val` = :val where `key` = 'u1001001' limit 1"; 如果此处val=$value下面代码不变则入库后反斜杠被去掉。这算是个手误。:val要和下面的execute对应 //$dbname='dev_cssg_s1_user'; //$host='192.16.12.131'; //$dsn='mysql:host='.$host.'; port=3306; dbname='.$dbname; //// 统一utf8编码 //$optArr=array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'); //$pdoObj=new PDO($dsn, 'root', 'root', $optArr); //$sth=$pdoObj->prepare($sql); //$ret = $sth->execute(array(':val'=>$value)); //var_dump($ret);
|
请发表评论