silbinarywolf / php-wordpress-database-tools
该包已被 废弃 并不再维护。作者建议使用 symbiote/php-wordpress-database-tools 包代替。
一组用于连接和查询 WordPress 数据库的类。该库的目的是轻松有效地遍历 WordPress 数据并将其导入其他 CMS 系统。
2.0.0
2018-09-07 05:29 UTC
Requires
- php: >=5.3.0
Replaces
This package is not auto-updated.
Last update: 2022-02-01 13:00:30 UTC
README
一组用于连接和查询 WordPress 数据库的类。该库的目的是轻松有效地遍历 WordPress 数据并将其导入其他 CMS 系统。
快速开始
- 设置 WordPress 数据库配置详情
<?php $wpDB = new WordpressDatabase(array( 'database' => 'wordpress-database', 'username' => 'root', 'password' => '', 'table_prefix' => 'wp' ));
- 遍历 WordPress 数据并对其进行操作。
<?php foreach ($wpDB->getPages() as $wpData) { $wpMeta = $wpDB->attachAndGetPostMeta($wpData); $newRecord = array(); $newRecord['Title'] = $wpDB->process('post_title', $wpData['post_title']); $newRecord['Permalink'] = $wpData['post_name']; $newRecord['Content'] = $wpDB->process('post_content', $wpData['post_content']); $newRecord['Created'] = $wpData['post_date']; $newRecord['LastEdited'] = $wpData['post_modified']; $newRecord['WordpressData'] = $wpData; // Since 'attachAndGetPostMeta' attaches the meta to $wpData, it'll store that too. }