Both frameworks have seperate Model, View, Controller directories. My doubt is how to use model in Zend Framework.
[ CodeIgniter Controller ]
<?php
class Users extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('users_model');
}
function index()
{
// here i am using model function //
$this->user_model->login();
}
}
?>
[ Zend Framework Controller ]
<?php
class UsersController extends Zend_Controller_Action
{
public function indexAction()
{
// how to load model and use here ???? //
}
}
?>
In CodeIgniter Controller I load model "users+_model" and used in index function. In the same way how to create zend model and use in controller? please hel开发者_Python百科p me, I am sorry my english is not good.
Thanks friends, Rajendra
It looks like you're stuck on the idea of "loading" a model. CI is a much more rigid system than ZF and almost shields the developer from working with Classes directly.
In ZF you declare classes in Models
or if you have modules enabled Default/Models
and work with them directly by instantiating them.
$dog = new Default_Model_Dog()
or even something like
$dog = Default_Model_Dog::createDog()
If you plan on working with a database a lot, then I STRONGLY suggest you learn Doctrine ORM and use that with ZF
http://www.doctrine-project.org/projects/orm
It's a fantastic piece of software that makes working a database much more bearable in ZF. It will take a little bit to learn, but it will pay back in time saved later on.
精彩评论