I'm working on a backend module that saves to a custom table. My problem is that I've added fields to this table as I've been working on it, the newly added fields won't save with the model ->Save() function.
I've completely removed the module and resinstalled it, letting it create my custom table from scratch in case it had some internal field count that I wasn't aware of, but still same result.
After adding my data I do a var dump on what gets submitted like this:
$model = Mage::getModel("smsmanager/sms")->addData($post_data)->save();
var_dump($model->getData()); exit;
With the result
array
'form_key' => string 'RUGN3fruWobAf8CZ' (length=16)
'message' => string 'adg asdg sad' (length=14)
'country' => string 'SE' (length=2)
'telephone' => string '+46707332290' (length=12)
'type' => int 2
'id' => string '5' (length=1)
And everything looks just fine. When I check the newly created row with ID 5, I get this:
|-----------------------------------------------------------------------------------------------------------|
|id int(11)| type int(11) | telephone varchar(20) | country varchar(2) | message text | date timestamp |
|-----------------------------------------------------------------------------------------------------------|
| 5 | 2 | +46707332290 | NULL | adg asdg sad | 2013-03-19 21:44:51 |
|-----------------------------------------------------------------------------------------------------------|
I've also tried to manually insert other fields into the database table like "junkfield" and add it with $post_data['junkfield'] = "hello";
and it also gets null as value.
For me, it's looking like Magento is screwing with me. Defying logic. Anybody got another take on what could be wrong? Oh and before I forget, here's my table layout:
CREATE TABLE IF NOT EXISTS `sms_entry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL,
`telephone` varchar(20) DEFAULT NULL,
`country` varchar(2) DEFAULT NULL,
`message` text,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
No matter what I try it just won't save the country code. I also tried making teh varchar larger then 2, switching name to country_code
(incase country was reserved or something). Nothing seems to help.
as far as I know - Magento caching database structure somehow. so just Flush Magento Cache should help
Disabling the caching options in Magento's Admin system does NOT disable all caching. Magento still caches table structures, locale data, etc., in the var/cache/
directory, under Magento's root folder (this is NOT /var/cache
).
To disable all caching, add the following <cache>
entry to the <global>
section of app/etc/local.xml
:
<config>
<global>
...
<cache>
<backend>Zend_Cache_Backend_BlackHole</backend>
</cache>
...
To flush the cache containing the table structures, go into the Admin system, and select System > Cache Management > Flush Cache Storage (not Flush Magento Cache!). This will remove the files in var/cache
.
You can also flush the cache via the command line:
$ sudo rm -fr /path/to/your/magento/installation/var/cache/*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With