ylliX - Online Advertising Network Magento direct SQL INSERT with safe parameters binding - Yet Another Programmer's Blog

Magento direct SQL INSERT with safe parameters binding

Maybe someone will find it usefull:

$write = Mage::getSingleton("core/resource")->getConnection("core_write");

$query = "insert into mytable "
       . "(field1, field2, field3, field4) values "
       . "(:field1, :field2, :field3, 12)";

$binds = array(
    'field1'   => "value 1",
    'field2' => "value 2",
    'field3'    => "value 3",
);
$write->query($query, $binds);

 

Leave a Reply