setDBO(VoxelCareDB::getDatabase()); } function getUserAddress($userid) { // consulto la base de datos por el userid $sql = "SELECT ua.id id, ua.userid userid, ua.company company, ua.address address, ua.city city, ua.province province, ua.pcode pcode, ua.country country, ua.phone phone, ua.delivery_schedule delivery_schedule FROM #__vxc_useraddress ua WHERE ua.userid = ".$userid; $this->_db->setQuery($sql); $row =& $this->_db->loadObject(); return $row; } function SetId($id) { $this->_id = (int)$id; $this->_item =null; } function getData() { if (empty($this->_item)) { $sql = "SELECT ua.id id, ua.userid userid, ua.company company, ua.address address, ua.city city, ua.province province, ua.pcode pcode, ua.country country, ua.phone phone, ua.delivery_schedule delivery_schedule FROM #__vxc_useraddress ua WHERE ua.id = ".$this->_id; $this->_db->setQuery($sql); $row =& $this->_db->loadObject(); if (!$row) { $row = new stdClass(); $row->id = 0; } $this->_item = $row; } return $this->_item; } function delete() { if (!$this->_id) return; $sql = "DELETE FROM #__vxc_useraddress WHERE id = ".$this->_id; $this->_db->Execute($sql); } function store(&$post) { $db =& $this->_db; $row =& $this->getTable('useraddress'); $row->reset(); $id = (int)$post['id']; $row->load($id); if (!$row->bind($post)) return false; if (!$row->check()) return false; if (!$row->store(true)) return false; $this->SetId($row->id); $post['id'] = $this->_id; return true; } } ?>