这是从mysql导出函数输出的。问题是我不知道将其放入Access的最佳方法。从那里我可以编写PHP来解析它。
<?php
/**
* Export to PHP Array plugin for PHPMyAdmin
* @author Geoffray Warnants
* @version 0.2b
*/
//
// Database "nhbdir_newdb3"
//
// nhbdir_newdb3.jos_banner
$jos_banner = array(
array('bid'=>1,'cid'=>1,'type'=>'banner','name'=>'OSM 1','alias'=>'osm-1','imptotal'=>0,'impmade'=>44,'clicks'=>0,'imageurl'=>'osmbanner1.png','clickurl'=>'http://www.opensourcematters.org','date'=>'2004-07-07 15:31:29','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'','catid'=>13,'description'=>'','sticky'=>0,'ordering'=>1,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>2,'cid'=>1,'type'=>'banner','name'=>'OSM 2','alias'=>'osm-2','imptotal'=>0,'impmade'=>50,'clicks'=>0,'imageurl'=>'osmbanner2.png','clickurl'=>'http://www.opensourcematters.org','date'=>'2004-07-07 15:31:29','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'','catid'=>13,'description'=>'','sticky'=>0,'ordering'=>2,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>3,'cid'=>1,'type'=>'','name'=>'Joomla!','alias'=>'joomla','imptotal'=>0,'impmade'=>279,'clicks'=>0,'imageurl'=>'','clickurl'=>'http://www.joomla.org','date'=>'2006-05-29 14:21:28','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'<a href=\"{CLICKURL}\" target=\"_blank\">{NAME}</a>
<br/>
Joomla! The most popular and widely used Open Source CMS Project in the world.','catid'=>14,'description'=>'','sticky'=>0,'ordering'=>1,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>4,'cid'=>1,'type'=>'','name'=>'JoomlaCode','alias'=>'joomlacode','imptotal'=>0,'impmade'=>279,'clicks'=>0,'imageurl'=>'','clickurl'=>'http://joomlacode.org','date'=>'2006-05-29 14:19:26','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'<a href=\"{CLICKURL}\" target=\"_blank\">{NAME}</a>
<br/>
JoomlaCode, development and distribution made easy.','catid'=>14,'description'=>'','sticky'=>0,'ordering'=>2,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>5,'cid'=>1,'type'=>'','name'=>'Joomla! Extensions','alias'=>'joomla-extensions','imptotal'=>0,'impmade'=>274,'clicks'=>0,'imageurl'=>'','clickurl'=>'http://extensions.joomla.org','date'=>'2006-05-29 14:23:21','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'<a href=\"{CLICKURL}\" target=\"_blank\">{NAME}</a>
<br/>
Joomla! Components, Modules, Plugins and Languages by the bucket load.','catid'=>14,'description'=>'','sticky'=>0,'ordering'=>3,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>6,'cid'=>1,'type'=>'','name'=>'Joomla! Shop','alias'=>'joomla-shop','imptotal'=>0,'impmade'=>274,'clicks'=>0,'imageurl'=>'','clickurl'=>'http://shop.joomla.org','date'=>'2006-05-29 14:23:21','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'<a href=\"{CLICKURL}\" target=\"_blank\">{NAME}</a>
<br/>
For all your Joomla! merchandise.','catid'=>14,'description'=>'','sticky'=>0,'ordering'=>4,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>7,'cid'=>1,'type'=>'','name'=>'Joomla! Promo Shop','alias'=>'joomla-promo-shop','imptotal'=>0,'impmade'=>50,'clicks'=>1,'imageurl'=>'shop-ad.jpg','clickurl'=>'http://shop.joomla.org','date'=>'2007-09-19 17:26:24','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'','catid'=>33,'description'=>'','sticky'=>0,'ordering'=>3,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>''),
array('bid'=>8,'cid'=>1,'type'=>'','name'=>'Joomla! Promo Books','alias'=>'joomla-promo-books','imptotal'=>0,'impmade'=>57,'clicks'=>0,'imageurl'=>'shop-ad-books.jpg','clickurl'=>'http://shop.joomla.org/index.php?option=com_wrapper&Itemid=8','date'=>'2007-09-19 17:28:01','showBanner'=>1,'checked_out'=>0,'checked_out_time'=>'0000-00-00 00:00:00','editor'=>'','custombannercode'=>'','catid'=>33,'description'=>'','sticky'=>0,'ordering'=>4,'publish_up'=>'0000-00-00 00:00:00','publish_down'=>'0000-00-00 00:00:00','tags'=>'','params'=>'')
);
答案 0 :(得分:1)
答案 1 :(得分:1)
这有点粗糙,但您可以将文件另存为CSV file,然后将其导入Excel,将其复制到剪贴板并粘贴到Access中:
/**
* save array as CSV file, first line will be keys as
* field specifier
*
* @param array $data
* @param string $filename
*/
function array_csv_save(array $data, $filename) {
$handle = fopen($filename, 'w');
$names = array_keys($data[0]);
fputcsv($handle, $names);
foreach($data as $fields) {
fputcsv($handle, $fields);
}
fclose($handle);
}
$data = $jos_banner;
$columns = array_keys($data[0]);
array_unshift($data, $columns);
array_csv_save($data, $filename);
指定$filename
以保存您的数据。
另一种方法是打开一个基于(odbc?)的数据库连接到Access数据库并插入您的值。但我不能流利,所以不能提供任何有用的代码。