Skip to content

Instantly share code, notes, and snippets.

@tarnfeld
Created October 3, 2011 20:40
Show Gist options
  • Select an option

  • Save tarnfeld/1260175 to your computer and use it in GitHub Desktop.

Select an option

Save tarnfeld/1260175 to your computer and use it in GitHub Desktop.
<?php
// First off, change
public function __construct($table, $id) ..
// to
public function __construct($table, $id = null) ..
// then only use the $id part if its not null
public static function create($table, array $properties) {
$x = new self($table);
foreach($properties as $k => $v) {
$x->{$k} = $v;
}
return $x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment