I am working on a new payment module for Magento and have come across an issue that I cannot explain. The following code that runs after the credit card is verified:
$table_prefix = Mage::getConfig()->getTablePrefix();
$tableName = $table_prefix.'authorizecim_magento_id_link';
$resource = Mage::getSingleton('core/resource');
$writeconnection = $resource->getConnection('core_write');
$acPI = $this->_an_customerProfileId;
$acAI = $this->_an_customerAddressId;
$acPPI = $this->_an_customerPaymentProfileId;
$sql = "insert into {$tableName} values ('', '$customerId', '$acPI', '$acPI', '3')";
$writeconnection->query($sql);
$sql = "insert into {$tableName} (magCID, anCID, anOID, anObjectType) values ('$customerId', '$acPI', '$acAI', '2')";
$writeconnection->query($sql);
$sql = "insert into {$tableName} (magCID, anCID, anOID, anObjectType) values ('$customerId', '$acPI', '$acPPI', '1')";
$writeconnection->query($sql);
I have verified using Firebug and FirePHP that the SQL queries are syntactically correct and no errors are returned.
The odd thing here is that I have checked the database, and the autoincrement value is incremented on every run of the code. However, no rows are inserted in the database. I have verified this by adding a die(); statement directly after the first write.
Any ideas why this would be occuring?
The relative portion of the config.xml is this:
<config>
<global>
<models>
<authorizecim>
<class>CPAP_AuthorizeCim_Model</class>
</authorizecim>
<authorizecim_mysql4>
<class>CPAP_AuthorizeCim_Model_Mysql4</class>
<entities>
<anlink>
<table>authorizecim_magento_id_link</table>
</anlink>
</entities>
<entities>
<antypes>
<table>authorizecim_magento_types</table>
</antypes>
</entities>
</authorizecim_mysql4>
</models>
<resources>
<authorizecim_setup>
<setup>
<module>CPAP_AuthorizeCim</module>
<class>CPAP_AuthorizeCim_Model_Resource_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</authorizecim_setup>
<authorizecim_write>
<connection>
<use>core_write</use>
</connection>
</authorizecim_write>
<authorizecim_read>
<connection>
<use>core_read</use>
</connection>
</authorizecim_read>
</resources>
</global>
</config>