Results 1 to 4 of 4

Thread: Doctrine and model classes

  1. #1
    Join Date
    Aug 2009
    Posts
    58

    Doctrine and model classes

    Imagine a user table. It will then generate the classes.
    Code:
    Doctrine::generateModelsFromDb('models', array('doctrine'), array('generateTableClasses' => true));
    Code:
    class User extends BaseUser
    {
    }
    Then we generated a skeleton doctrine_Table
    Code:
    class UserTable extends Doctrine_Table
    {
    }
    In the documentation it says that.
    You can place custom functions inside the User and UserTable classes to customize the functionality of your models. Below are some examples:
    I do not understand the difference between these two classes, what is the role of each of them and must contain?

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Doctrine and model classes

    Normally in user you add methods to your object.

    It could be for example a method getAge() which, from the date of birth of your user, would directly calculate its age.

    Or for example, a loc () method that would block a user account if it is wrong 3 times in his login.

    In usertable you add methods which mostly involve making Doctrine_Query.

    The goal in general is that methods of your usertable return a User object or a collection of User objects.

  3. #3
    Join Date
    Aug 2009
    Posts
    58

    Re: Doctrine and model classes

    But I do not understand why they do this:

    Code:
    class JobeetJobTable extends Doctrine_Table
    {
      static public $types = array(
        'full-time' => 'Full time',
        'part-time' => 'Part time',
        'freelance' => 'Freelance',
      );
      public function getTypes()
      {
        return self::$types;
      }
      // ... 
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Doctrine and model classes

    This case is also justified. You're not going to put this method in JobeetJob. In JobeetJob, you getType() that you will return the type for the object. In JobeetJobTable, you getType() which returns you the different types available. Or, is what you would put it otherwise?

Similar Threads

  1. Victoria 2 Doctrine of Lapse Event
    By Dyutit in forum Video Games
    Replies: 9
    Last Post: 27-01-2012, 11:25 PM
  2. Replies: 8
    Last Post: 05-12-2011, 09:20 PM
  3. china mobile phone model: "INCOMP Model:W902A"
    By gerardmodeste in forum Portable Devices
    Replies: 1
    Last Post: 04-01-2010, 09:10 AM
  4. C # using classes in C + +
    By klite in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:15 AM
  5. Classes in VB.NET
    By Samir_1 in forum Software Development
    Replies: 2
    Last Post: 10-04-2009, 12:07 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,777,991.62941 seconds with 17 queries