PHP code example of symbiote / php-wordpress-database-tools

1. Go to this page and download the library: Download symbiote/php-wordpress-database-tools library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

symbiote / php-wordpress-database-tools example snippets



$wpDB = new WordpressDatabase(array(
	'database' 	 	 => 'wordpress-database',
	'username'		 => 'root',
	'password'		 => '',
	'table_prefix'   => 'wp'
));


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.
}