1

我想执行以下命令:

INTO TABLE example_table FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' (field1,field2,field3);

我试图这样:

$app = Mage::app();

umask(0);

Mage::setIsDeveloperMode(true);

$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$write->query("INTO TABLE example_table
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n'
(field1,field2,field3)");

我也想CREATE OR REPLACE VIEW...TRUNCATE example_table

我得到的错误是:

Error: Warning: PDOStatement::execute(): LOAD DATA LOCAL INFILE forbidden in \lib\Zend\Db\Statement\Pdo.php on line 228

4

1 回答 1

3

好的,问题解决了。

$dbConfig = array(
    'host'      => 'HOST',
    'username'  => 'USER',
    'password'  => 'PASS',
    'dbname'    => 'DBNAME',
    'driver_options'=> array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8')
);
$db_magento = Zend_Db::factory('Pdo_Mysql', $dbConfig);
$db_magento->query("TRUNCATE table1");
    $db_magento->query("LOAD DATA INFILE '{$file_name}'
    INTO TABLE table1
    FIELDS TERMINATED BY ';'
    LINES TERMINATED BY '\n'
    (field1,field2,field3)");

我无法使用LOAD DATA LOCAL INFILE,但没有LOCAL它可以工作。

于 2012-07-12T14:13:46.767 回答