Please, take a look only at that class, I understand that a bit of code outdoors of the application informs little by what should really do, however i think you realize what's essentially designed to do and for use for.


class Customer
   const DB_TABLE = 'customers';

   public $id = NULL;
   //all other properties here

   function __construct($associative_array = NULL)
      //fills object properties using values provided by associative array

   static function load($customer_id)
      $obj = new static(); //PHP 5.3 we use static just in case someone in future wants to overide this in an inherited class

      //here we would load data from DB_TABLE and fill the $obj

      return $obj;

   static function delete($customer_id)
      //here we just delete the row in the DB_TABLE based on $customer_id (which is the primary key of the table)

   function save()
      //saves $this properties into a row of DB_TABLE by either updating existing or inserting new one

Besides any kind of comments that you'd make around the code (which are always appreciated), the primary question here's: "getting read a lot around on SO about how exactly bad are static techniques, and use of static generally, within this code can you result in the two techniques load/delete not static? If so why, would you explain having a small example."

It appears odd in my experience not to ensure they are static cause I believe it's odd to be able to produce a new object loaded from DB to have to write each time:

$obj = new Customer(); //creating empty object
$obj->load(67); //loading customer with id = 67

rather than simply doing

$obj = Customer::load(67); //creates a new customer and loads data form DB

Everything is dependent how you would like you code to become structure. IMO static functions are pretty good as lengthy as they are being used properly.

For instance, my models features offer a similar experience check the information here structure:

class models_car {
    public static function getCar($id);
    public static function getCars();
    public static function getCarsByDriver(models_driver $driver);
    public function save();
    public function delete();
    public function isNew();
    public function getProperty1();
    public function getProperty2();
    public function getProperty3();
    public function setProperty1($value);
    public function setProperty2($value);
    public function setProperty3($value);

So in here, you should use the model like a representation of the specific entry, and when you call remove or save, it's contacted the context from the object itself. Should you call the getCar, getCars or getCarsByDriver, they're static because they do not have to do with a particular object, they're loaders that return a filled object.

Go ahead and, this does not mean it's the perfect method but it is one i have used for a long time and contains shown to create excellent and workable code.