public function __construct($id = NULL)
 {
     parent::__construct();
     if ($id != NULL and (ctype_digit($id) or is_int($id))) {
         // try and get a row with this ID
         $data = $this->db->getwhere($this->table_name, array('id' => $id))->result(FALSE);
         // try and assign the data
         if (count($data) == 1 and $data = $data->current()) {
             foreach ($data as $key => $value) {
                 $this->data[$key] = $value;
             }
         }
     } else {
         if ($id != NULL and is_string($id)) {
             // try and get a row with this username/email
             $data = $this->db->orwhere(array('url_name' => $id))->get($this->table_name)->result(FALSE);
             // try and assign the data
             if (count($data) == 1 and $data = $data->current()) {
                 foreach ($data as $key => $value) {
                     $this->data[$key] = $value;
                 }
             }
         }
     }
 }
 public function __construct($id = NULL)
 {
     parent::__construct();
     if ($id != NULL and (ctype_digit($id) or is_int($id))) {
         // try and get a row with this ID
         $data = $this->db->getwhere($this->table_name, array('id' => $id))->result(FALSE);
         // try and assign the data
         if (count($data) == 1 and $data = $data->current()) {
             foreach ($data as $key => $value) {
                 $this->data[$key] = $value;
             }
         }
     } else {
         if ($id != NULL and is_string($id)) {
             list($album, $photo_filename) = explode('/', $id);
             $album = new Album_Model($album);
             $where = array('album_id' => $album->id);
             if (ctype_digit($photo_filename)) {
                 $where['id'] = $photo_filename;
             } else {
                 $where['photo_filename'] = $photo_filename;
             }
             // try and get a row with this username/email
             $data = $this->db->where($where)->get($this->table_name)->result(FALSE);
             // try and assign the data
             if (count($data) == 1 and $data = $data->current()) {
                 foreach ($data as $key => $value) {
                     $this->data[$key] = $value;
                 }
             }
         }
     }
 }