type:
integration
system:
MySQL
name:
XML Backup
description:
Store/backup your raw XML datafeeds in a MySQL database. Useful to back them up for future use.
tags:
xml,
mysql,
backup

Raw XML -> MySQL

This can be handy for a variety of uses. Once you have your order information locally, the possibilities are endless.

This is for advanced users. The code below just dumps the XML into a MySQL table, not much more. You could use this as a starting point, but you'll need to know what you're doing to make it do anything.
<?
# schema:
# CREATE TABLE CREATE TABLE `foxy_orders` (
# `id` int(11) NOT NULL auto_increment,
# `order_id` int(11) default NULL,
# `foxy_data` text NOT NULL,
# `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
# `processed_at` datetime default NULL,
# PRIMARY KEY (`id`)
# ) ENGINE=MyISAM AUTO_INCREMENT=227 DEFAULT CHARSET=utf8
//
// Finally, set your key to decrypt the XML that you receive from FoxyCart.
// This must match *exactly* what you entered at http://www.foxycart.com/admin
$key = "abracadabra";
 
if (isset($_POST["FoxyData"])) {
	// ===================================================================================================
	// DECRYPT YOUR DATA
	// (do not modify)
	// ===================================================================================================
	// Decrypt the data using your $key
	// First, include the rc4crypt.php file
	include 'class.rc4crypt.php';
	// Then decrypt the XML
	$FoxyData_encrypted = urldecode($_POST["FoxyData"]);
	$FoxyData_decrypted = rc4crypt::decrypt($key,$FoxyData_encrypted);
 
	// ===================================================================================================
 
	if (!mysql_connect('DBHOST', 'DBUSER', 'DBPASS')) die("no connection to MySQL");
	if (!mysql_select_db('not4sale_production')) die("couldn't select database");
 
	mysql_query("INSERT INTO foxy_orders (created_at,foxy_data) VALUES (NOW(),'".mysql_escape_string($FoxyData_decrypted) ."')");
 
	echo "foxy";
} else {
	echo "no post data!";
}
?>
 
integration/mysql.txt · Last modified: 2008/03/09 03:45 by foxybrett
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki