简体   繁体   English

如何将此php数组文件解析为Access?

[英]How do I parse this php array file into Access?

This is output from a mysql export function. 这是从mysql导出函数输出的。 Problem is I don't know the best way to put this into Access. 问题是我不知道将其放入Access的最佳方法。 From there I can write PHP to parse it. 从那里我可以编写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'=>'')
);

have you tried just exporting from mysql to a .csv and then import that CSV into access? 你试过从mysql导出到.csv,然后导入该CSV进入访问? Save the .csv file and open it with access and it should prompt you with a wizard to import the data. 保存.csv文件并使用访问权限打开它,它应该提示您使用向导导入数据。

This is a bit rough, but you can save a file as a CSV file and then import it into Excel, copy it over to your clipboard and paste it into Access: 这有点粗糙,但您可以将文件另存为CSV文件 ,然后将其导入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);

Specify $filename to save your data. 指定$filename以保存数据。

The other alternative is to open a ( odbc ?) based database connection to your Access database and insert your values. 另一种方法是打开一个基于( odbc ?)的数据库连接到Access数据库并插入您的值。 But I'm not fluent with that, so can't provide any useful code. 但我不能流利,所以不能提供任何有用的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM