O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating a User object

Now that we have our Base class created, let's create a User class that will house the properties and functions for all things related to users.

  1. Create a new file called user.php, and place it in the classes folder along with base.php.
  2. Let's create a class that extends our Base class.
    <?php
    class User extends Base
    {
    }
    
  3. Let's add the two properties that we know we need so far: name and email, into our User class.
    <?php
    class User extends Base
    {
    protected $name;
    protected $email;
    
    }
    
  4. Let's add a __construct function that will tell our Base class that our document type is user on creation.
    <?php
    class User extends Base
    {
    protected $name;
    protected $email;
    public function __construct() { parent::__construct('user'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required