pdo执行数据库文件案例

      发布在:数据库技术      评论:0 条评论
<pre style="background-color:#262e37;color:#ffffff;font-family:&#39;Consolas&#39;,monospace;font-size:11.3pt;">$dbms = &quot;mysql&quot;; // 数据库的类型<br/>$user = &quot;root&quot;; //使用的数据库用户名<br/>$pwd = &quot;root&quot;; //使用的数据库密码<br/>$host = &quot;127.0.0.1&quot;; //使用的主机名称<br/>$dsn = &quot;$dbms:host=$host&quot;;<br/>$sqls=[&#39;localhost.sql&#39;];<br/>$pdo = new \PDO($dsn,$user,$pwd); //实例化对象<br/>foreach ($sqls as $sql){<br/> $sql=file_get_contents($sql);<br/> $pdo-&gt;exec($sql);//执行添加语句并返回受影响行数<br/>}<br/></pre><p><br/></p>
相关文章
热门推荐