Skip to content

Instantly share code, notes, and snippets.

@jwoodcock
Created August 20, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwoodcock/75f7e73cd416f058f732 to your computer and use it in GitHub Desktop.
Save jwoodcock/75f7e73cd416f058f732 to your computer and use it in GitHub Desktop.
Map Class
class MyMap
{
public $user_id;
public $first_name;
public $last_name;
public $email;
public function __set($key, $val)
{
// can't set the user_id, that's a db item
if ($key != $user_id) {
$this[$key] = $val;
}
}
public function save()
{
if (!empty($this->user_id) {
// save call
// sql code goes here
} else {
// update call
// sql code goes here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment