Anonymous Anonymous - 6 months ago
190 0

No description

PHP

PHP Entity FW WIP

<?php
/*

   The Item and Items class allow for rapid development of schema.

   In order to create a new table schema for storing an
   object, simply define a class with an $attrs array with
   all of the 'columns' you want to have: 

 */
class Employee extends Item {

    public $attrs = array(
            "username",         //1
            "firstname",        //2
            "lastname",         //3
            "hired",            //4
            "parted",           //5
            "reasonforleaving", //6
            "isrobot"           //7
            ); 

    // The following two things allow you to make a pointer to consistent
    // properties for all objects so that there may be unified templates
    // which will work for all objects. 

    protected $fname = "firstname";
    protected $lname = "lastname"; 

}

/* 
Create: 

new Employee(array( "username"=>"jpope",
"fname" =>"james",
"lname" =>"pope"
)); 

Read: 

$empl = Employee::init("fname", "james"); 
-or- 
$empl = Employee::init((int) $id);



Update: 

Employee::init($id)->update("parted",time()); 


Delete: 

Employee::delete($id); 

 */


/**
    BULK FETCH: 


   $employees = Employees::fetchAll(); 
// returns an array of Employee Objects


 */
Comments