Raw Database Queries
The attached link describes everything fantastically, just go there.
Related cards:
Enabling MySQL Query Logging
In /lib/Varien/Db/Adapter/Pdo/Mysql.php change this property to true:
/**
* Write SQL debug data to file
*
* @var bool
*/
protected $_debug = false;
To enable logging for queries slower than a certain ti...
Getting A Database Adapter (Read or Write)
To read:
Mage::getSingleton('core/resource')->getConnection('core_read');
To write:
Mage::getSingleton('core/resource')->getConnection('core_write');
Remove Customers From MySQL
Is this ok?
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_...
Remove Orders From MySQL
What version did flat come in? Are all these tables safe to truncate? Make different scripts for different versions.
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
...
Magento Multi Database Guide
Handy link to a very useful PDF which details how to handle multiple databases in Magento.
Database Schema
This site shows details of the Magento database schema for differing versions - it shows foreign key relationships in a nice drag-and-drop interface
Fetching All Attributes For An Entity From The DB In One Query
Using the database to inspect EAV-based entity types can be a real pain in the ass, so here are a bunch of queries that let you inspect some popular EAV entity types easily. This practice can be applied to any EAV entity type, however as there are...
Config Redis Cache Definition
You need Cm_Cache_Backend_Redis for this
<config>
<global>
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
...
startSetup() and endSetup()
Ever wondered what they do? Basically they disable and then enable foreign key checks, and set the SQL mode to NO_AUTO_VALUE_ON_ZERO, then back to the old SQL mode. Below is the code taken from Varien_Db_Adapter_Pdo_Mysql
:
/**
* Run ad...
Magento Version History
Here is a table showing major changes over the Magento version history:
| CE | PE | EE | Year | Major Changes ...