Create model for front-end module in magento1

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_Usemodel.xml file in app/etc/modules/.
where Mywork is Namespace and Usemodel is Modulename.
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Usemodel>
<active>true</active>
<codePool>local</codePool>
</Mywork_Usemodel>
</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/Usemodel/etc/config.xml
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Usemodel>
<version>1.0.0</version>
</Mywork_Usemodel>
</modules>

<frontend>
<routers>
<usemodel>
<use>standard</use>
<args>
<module>Mywork_Usemodel</module>
<frontName>usemodel</frontName>
</args>
</usemodel>
</routers>

<layout>
<updates>
<usemodel>
<file>usemodel.xml</file>
</usemodel>
</updates>
</layout>
</frontend>

<global>
<blocks>
<usemodel>
<class>Mywork_Usemodel_Block</class>
</usemodel>
</blocks>

<models>
<usemodel>
<class>Mywork_Usemodel_Model</class>
<resourceModel>usemodel_mysql4</resourceModel>
</usemodel>
<usemodel_mysql4>
<class>Mywork_Usemodel_Model_Mysql4</class>
<entities>
<getadmin>
<table>admin_user</table>
</getadmin>
</entities>
</usemodel_mysql4>
</models>
</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 usemodel,
and we access the extension value from siteurl/usemodel.

Step3:- Now we create the IndexController.php in app/code/local/Mywork/Usemodel/controllers/IndexController.php
[php]
<?php
class Mywork_Usemodel_IndexController extends Mage_Core_Controller_Front_Action {

public function indexAction() {

$this->loadlayout();
$this->renderlayout();
}

}
?>
[/php]

Step4:- Now create the Usemodel.php in app/code/local/Mywork/Useblock/Block/Usemodel.php
[php]
<?php
class Mywork_Usemodel_Block_Usemodel extends Mage_Core_Block_Template
{

public function _prepareLayout()
{

return parent::_prepareLayout();
}

}

[/php]

Step5:- Now create the Getadmin.php in app/code/local/Mywork/Usemodel/Model/Getadmin.php
[php]
<?php

class Mywork_Usemodel_Model_Getadmin extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init(‘usemodel/getadmin’);
}
}
[/php]

Step6:- Now create the Getadmin.php in app/code/local/Mywork/Usemodel/Model/Mysql4/Getadmin.php
[php]
<?php

class Mywork_Usemodel_Model_Mysql4_Getadmin extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
// Note that the user_id refers to the key field in your database table.
$this->_init(‘usemodel/getadmin’, ‘user_id’);
}

}
[/php]

Step7:- Now create the Collection.php in app/code/local/Mywork/Usemodel/Model/Mysql4/Getadmin/Collection.php
[php]
<?php

class Mywork_Usemodel_Model_Mysql4_Getadmin_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init(‘usemodel/getadmin’);
}
}
[/php]

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

Step9:- Now create the usemodel.phtml in app/design/frontend/default/default/template/usemodel/usemodel.phtml
[php]
<?php
$admin_userModel = Mage::getModel(‘usemodel/getadmin’)->load(1);
echo $admin_userModel->firstname;
echo $admin_userModel->lastname;
?>
[/php]

Note:- call the url
siteurl/usemodel Output:- Johnkumar