title: Difference between Data Access Layer and Model in MVC
body: <p>I have implemented what I thought was a pretty decent representation of MVC in several web applications but since having joined crackoverflow, I'm finding that perhaps my initial definitions were a bit simplistic and thus I'd really like some clarification on the differences between the Data Access Layer and the Model or Domain Layer of a web application.</p>
  
  <p>For context, I currently use data access objects that implement the CRUD functions for a single record in the table that the object represents as well as a get() function that returns an object that allows me to iterate through all of the objects that met the criteria for the get() function. </p>
  
  <p>These data access objects are referenced directly from the controller scripts which contain my business logic.</p>
  
  <p>If it matters, I'm working in PHP and MySQL but am interested in suggestions that might be coded in other languages.</p>
  
  <p><b>UPDATE:</b> For a more specific example, I have table called user (the convention here is singular table names) which holds such information as email address, active state, user name, password, which company they belong to, etc. This basic object would look like this in code:</p>
  
  <pre><code>class User implements DataAccessObject
  {
       protected $user_id;
       protected $email;
       protected $username;
       protected $password;
       protected $company_id;
       protected $active // Bool that holds either a 0 or 1
  
       public function __construct ( $user_id ) // Uses Primary Key to know which record to construct
       {
            $sql = //Sql to get this information from the database.
  
            // Code necessary to assign member variables their values from the query.
       }
  
       public function insert(){}
       public function update(){}
       public function delete(){}
       public static function get($filters, $orderVals, $limit){}
  
       // An object such as user might also contain the following function definition
       public static function login($username, $password){}
  }
  </code></pre>
  
  <p>It sounds like I might have bastardized the DAO Layer and Model layer into a simplified form that combines both any real-world type functions (such as login for a user) with the data access functions. </p>