Create table for custom magento1 module

Note:- you can download code from this rar_image
Note:-1) Firstly Disable all cache from the Cache Management tab in System tab.
2) select the default theme of the Magento from the System->Design.

Step1:- Create Mywork_Createtable.xml file in app/etc/modules/.
where Mywork is Namespace and Createtable is Modulename.
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Createtable>
<active>true</active>
<codePool>local</codePool>
</Mywork_Createtable>
</modules>
</config>
[/php]
Note:- 1) If you want to active the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create our own extension then we use the local code pool.

Step2:- Now create the config.xml file in app/code/local/Mywork/Createtable/etc/config.xml
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Createtable>
<version>1.0.0</version>
</Mywork_Createtable>
</modules>

<frontend>
<routers>
<createtable>
<use>standard</use>
<args>
<module>Mywork_Createtable</module>
<frontName>createtable</frontName>
</args>
</createtable>
</routers>
<layout>
<updates>
<createtable>
<file>createtable.xml</file>
</createtable>
</updates>
</layout>
</frontend>

<global>

<blocks>
<createtable>
<class>Mywork_Createtable_Block</class>
</createtable>
</blocks>

<models>
<createtable>
<class>Mywork_Createtable_Model</class>
<resourceModel>createtable_mysql4</resourceModel>
</createtable>
<createtable_mysql4>
<class>Mywork_Createtable_Model_Mysql4</class>
<entities>
<myinfo>
<table>myinfo</table>
</myinfo>
</entities>
</createtable_mysql4>
</models>

<resources>
<createtable_setup>
<setup>
<module>Mywork_Createtable</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</createtable_setup>

<createtable_write>
<connection>
<use>core_write</use>
</connection>
</createtable_write>
<createtable_read>
<connection>
<use>core_read</use>
</connection>
</createtable_read>

</resources>
</global>
</config>
[/php]

Note:- 1) In this file we created a version of this module is 1.0.0
2) In the frontend tag, we created routers tag. In routers tag, we define the frontend name is createtable,
and we access the extension value from siteurl/createtable.

Step3:- Now we create the IndexController.php in app/code/local/Mywork/Createtable/controllers/IndexController.php
[php]
<?php
class Mywork_Createtable_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
[/php]

Step4:- Now create the Useblock.php in app/code/local/Mywork/Createtable/Block/Createtable.php
[php]
<?php
class Mywork_Createtable_Block_Createtable extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
}
[/php]

Step5:- Now create the Myinfo.php in app/code/local/Mywork/Createtable/Model/Myinfo.php
[php]
<?php
class Mywork_Createtable_Model_Myinfo extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init(‘createtable/myinfo’);
}
}
[/php]

Step6:- Now create the Myinfo.php in app/code/local/Mywork/Createtable/Model/Mysql4/Myinfo.php
[php]
<?php
class Mywork_Createtable_Model_Mysql4_Myinfo extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
// Note that the img_id refers to the key field in your database table.
$this->_init(‘createtable/myinfo’, ‘my_id’);
}
}
[/php]

Step7:- Now create the Myinfo.php in app/code/local/Mywork/Createtable/Model/Mysql4/Myinfo/Collection.php
[php]
<?php
class Mywork_Createtable_Model_Mysql4_Myinfo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init(‘createtable/myinfo’);
}
}
[/php]

Step8:- Now create the mysql4-install-1.0.0.php in app/code/local/Mywork/Createtable/sql/createtable_setup/mysql4-install-1.0.0.php
[php]
<?php
$installer = $this;
$installer->startSetup();

$installer->run("
CREATE TABLE IF NOT EXISTS {$this->getTable(‘myinfo’)} (
`my_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`my_name` varchar(500) NOT NULL,
`my_image` varchar(500) NOT NULL,
`about_me` text NOT NULL,
PRIMARY KEY (`my_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
[/php]

Step9:- Now create the createtable.xml in app/design/frontend/default/default/layout/createtable.xml
[php]
<?xml version="1.0"?>
<layout version="1.0">
<createtable_index_index>
<reference name="content">
<block type="createtable/createtable" name="createtable" template="createtable/createtable.phtml" />
</reference>
</createtable_index_index>
</layout>
[/php]

Step10:- Now create the createtable.phtml in app/design/frontend/default/default/layout/createtable/createtable.phtml
[php]
<?php
$admin_userModel = Mage::getModel(‘createtable/myinfo’);
print_r($admin_userModel);
?>
[/php]

Note:- call the url
siteurl/createtable Output:- Mywork_Createtable_Model_Myinfo Object ( [_eventPrefix:protected] => core_abstract [_eventObject:protected] => object [_resourceName:protected] => createtable/myinfo [_resource:protected] => [_resourceCollectionName:protected] => createtable/myinfo_collection [_cacheTag:protected] => [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ( ) [_hasDataChanges:protected] => [_origData:protected] => [_idFieldName:protected] => [_isDeleted:protected] => [_oldFieldsMap:protected] => Array ( ) [_syncFieldsMap:protected] => Array ( ) )