I have a custom module. I am using this module to upload images through admin. I have 6 more form fields in my module. I am currently using one table to store values of these form fields. However as like in magento, i am planning to store image values in another table. My table structure is given below.
Table : Banner
Fields : banner_id( primary_key , int(11) )
banner_name( varchar (250) )
banner_count( small_int (6) )
status( small_int (6) )
store_id( varchar (250) )
Table : banner_images
Fields : bi_id( primary_key , int (11) )
banner_id( int (11) ) //this should be the 'banner_id' of banner which holds this imge
bi_name( varchar (255) ) //stores image_name
My current edit file look like this:
<?php
class Karaokeshop_Banner_Block_Adminhtml_Banner_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'banner';
$this->_controller = 'adminhtml_banner';
$this->_updateButton('save', 'label', Mage::helper('banner')->__('Save Banner'));
$this->_updateButton('delete', 'label', Mage::helper('banner')->__('Delete Banner'));
}
public function getHeaderText()
{
if( Mage::registry('banner_data') && Mage::registry('banner_data')->getId() )
{
return Mage::helper('banner')->__("Edit Banner");
}
else
{
return Mage::helper('banner')->__('Add Banner');
}
}
}
My sql file look like this :
?php
$installer = $this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('banner')};
CREATE TABLE {$this->getTable('banner')} (
`banner_id` int(11) unsigned NOT NULL auto_increment,
`banner_name` varchar(255) NOT NULL default '',
`banner_count` smallint(6) NOT NULL default '0',
`status` smallint(6) NOT NULL default '0',
`store_id` varchar(255) NOT NULL default '',
`img` varchar(255) NOT NULL default '',
PRIMARY KEY (`banner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
How can I achieve this? Please provide links, if there is any tutorials for this. Thanks in advance.