<?php
$installer = $this;
echo 'Running This Installation: '.get_class($this)."\n <br /> \n";
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('amber_maintenance_mode'))
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
), 'Id')
->addColumn('state', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'nullable' => false,
), 'State'
)
->addColumn('created_by', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
'nullable' => false,
), 'Created by'
)
->addColumn('start_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
'nullable' => true,
'default' => null,
'comment' => 'Start date'
), 'Start Date'
)
->addColumn('end_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
'nullable' => true,
'default' => null,
'comment' => 'End date'
), 'End Date'
)
->addColumn('down_reason', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
'nullable' => false,
), 'Down reason'
);
$installer->getConnection()->createTable($table);
$installer->endSetup();
Now trying to get data from table ....
$date = Mage::getModel('amber/maintenance_mode')->getCollection();
$date = Mage::getModel('amber_maintenance_mode')->getCollection();
$date = Mage::getModel('amber_maintenance/amber_maintenance_mode')->getCollection();
Nothing works ...... what I'm doing wrong ? Which form is correct if any ?
Here is my config "required section" ;)
<models>
<amber_maintenance>
<class>Amber_Maintenance_Model</class>
<resourceModel>maintenance_mysql4</resourceModel>
</amber_maintenance>
<amber_maintenance_resource>
<class>Amber_Maintenance_Model_Resource</class>
<entities>
<mode>
<table>amber_maintenance_mode</table>
</mode>
</entities>
</amber_maintenance_resource>
</models>
<resources>
<maintenance_setup>
<setup>
<module>Amber_Maintenance</module>
<class>Mage_Core_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</maintenance_setup>
<maintenance_write>
<connection>
<use>core_write</use>
</connection>
</maintenance_write>
<maintenance_read>
<connection>
<use>core_read</use>
</connection>
</maintenance_read>
</resources>
config.xml
and model file code$date = Mage::getModel('amber_maintenance/mode')->getCollection();
should get you your data.