我正在使用以下脚本:
<?php
ini_set('max_execution_time', 0);
ini_set('error_reporting', E_ALL);
$file = file_get_contents('./dump.sql');
//var_dump($file); die();
$conn = new mysqli('localhost', 'myUserName', 'myPassWord', 'myDataBase');
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . $conn->host_info . "<br />";
echo 'Retrieving dumpfile' . "<br />";
$sql = $file;
if (!$sql){
die ('Error opening file');
}
echo 'processing file <br />';
mysqli_multi_query($conn,$sql);
echo 'done.';
$conn->close();
?>
它输出以下内容,一切似乎都很顺利,没有任何错误:
Success... localhost via TCP/IP
Retrieving dumpfile
processing file
done.
但是,我的数据库中没有字段。什么都没有添加。
我的 dump.sql 文件中的第一行代码如下:
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 05, 2012 at 04:01 PM
-- Server version: 5.5.16
-- PHP Version: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `myDataBase`
--
-- --------------------------------------------------------
--
-- Table structure for table `content_field_image_cache`
--
CREATE TABLE IF NOT EXISTS `content_field_image_cache` (
`vid` int(10) unsigned NOT NULL DEFAULT '0',
`nid` int(10) unsigned NOT NULL DEFAULT '0',
`delta` int(10) unsigned NOT NULL DEFAULT '0',
`field_image_cache_fid` int(11) DEFAULT NULL,
`field_image_cache_list` tinyint(4) DEFAULT NULL,
`field_image_cache_data` text,
PRIMARY KEY (`vid`,`delta`),
KEY `nid` (`nid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `content_field_image_cache`
--
INSERT INTO `content_field_image_cache` (`vid`, `nid`, `delta`, `field_image_cache_fid`, `field_image_cache_list`, `field_image_cache_data`) VALUES
(1000, 1000, 0, 1000, 1, NULL),
(1001, 1001, 0, 1001, 1, NULL),
(1002, 1002, 0, 1002, 1, NULL),
(1003, 1003, 0, 1003, 1, NULL),
为什么这段代码不起作用?谢谢。