标题: 在zf中,如何将csv数据导入mysql?
honking
新手上路
Rank: 1



UID 1191
精华 0
积分 0
帖子 2
翻译 0
原创 0
阅读权限 10
注册 2008-5-16
状态 离线
发表于 2008-7-1 23:20  资料  短消息  加为好友 
在zf中,如何将csv数据导入mysql?

在zf中,如何将csv数据导入mysql?

就是使用这样的命令
load data infile 'e:\\book1.csv' into table contents  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' (book_id,title,chapter,section,page_num);
我下列的代码会报错
Mysqli prepare error: This command is not supported in the prepared statement protocol yet

<?php
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Db_Statement');

class Contents extends Zend_Db_Table
{
        protected $_name = 'contents';
        protected $_primary = 'id';

        public function importFromCsv($path)
        {
                $db = $this->getAdapter();
                $path = $db->quote($path);
                $sql = "load data infile $path into table contents FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' (book_id,title,chapter,section,page_num);";
                $result = $db->query($sql);
        }

}
?>

[ 本帖最后由 honking 于 2008-7-1 23:22 编辑 ]

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2008-9-7 16:19

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.012755 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver