PHP使用PDO连接MYSQL
1 $serve = 'mysql:host=数据库地址;dbname=数据库名;charset=utf8'; 2 $username = 数据库帐号; 3 $password = 数据库密码; 4 $PDO = new PDO($serve,$username,$password); 5 $result = $PDO->query('insert into lyh_article (cid,comid,title,content,imagefile,source,datetime) values ('.$intocid.','.$comid.',"'.$title.'","'.$content.'","'.$imagefile.'","'.$source.'",'.$datetime.')'); 6 $result->fetchAll(PDO::FETCH_ASSOC);