Hello,

To explain what I'm trying to say I will put an example.

For people that come from PHP frameworks like Zend or Code Igniter we
use the models on the following way:

First, we write each model on a file (like web2py) for example:


<?php
class Usermodel extends Model {

    function Usermodel()
    {
        // Call the Model constructor
        parent::Model();

        $this->load->database();

    }

   function findUser($login)
   {
        $sql = "select * from users where login_name='$login'";
        $query = $this->db->query($sql);

        $result = $query->result_array();
        return $result;
   }
}
?>

And second, we use that model on the controller like this:

<?php
class Login_user extends Controller
{
    function Login_user()
    {
        parent::Controller();

        $this->load->model('Usermodel');
    }

    function index()
    {
      ...............
      $id_user = $this->Usermodel->findUser($login);

    }
}
?>

What I'm trying to say is that on these frameworks we use the models
to put all the related stuff with the sql queries. We call from the
controllers functions that are implemented on the models avoiding to
write sql queries on the controllers.

I said that because on web2py documentation I have seen models that
only describe the tables, fields, and other things related to the
database and in some examples I have seen on the controllers code
related to queries that in my opinion it should be on a model.

I do not if it's clear what I'm saying but could some one put an
example of how could I use the models in web2py on the same way that
for example in codeIgniter.

Thanks a lot



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to