iVendorId = $iVendorId; $this->sName = $oRow->vendorName; $this->sWebpage = $oRow->vendorURL; } /* * We fetch applicationsIds. */ $sQuery = "SELECT appId FROM appFamily WHERE vendorId = '?'"; if($hResult = query_parameters($sQuery, $iVendorId)) { while($oRow = mysql_fetch_object($hResult)) { $this->aApplicationsIds[] = $oRow->appId; } } } } /** * Creates a new vendor. */ function create() { $hResult = query_parameters("INSERT INTO vendor (vendorName, vendorURL) ". "VALUES ('?', '?')", $this->sName, $this->sWebpage); if($hResult) { $this->iVendorId = mysql_insert_id(); $this->vendor($this->iVendorId); return true; } else { addmsg("Error while creating a new vendor.", "red"); return false; } } /** * Update vendor. * Returns true on success and false on failure. */ function update() { if(!$this->iVendorId) return $this->create(); if($this->sName) { if (!query_parameters("UPDATE vendor SET vendorName = '?' WHERE vendorId = '?'", $this->sName, $this->iVendorId)) return false; $this->sName = $sName; } if($this->sWebpage) { if (!query_parameters("UPDATE vendor SET vendorURL = '?' WHERE vendorId = '?'", $this->sWebpage, $this->iVendorId)) return false; $this->sWebpage = $sWebpage; } return true; } /** * Deletes the vendor from the database. */ function delete($bSilent=false) { if(sizeof($this->aApplicationsIds)>0) { addmsg("The vendor has not been deleted because there are still applications linked to it.", "red"); } else { $sQuery = "DELETE FROM vendor WHERE vendorId = '?' LIMIT 1"; if(query_parameters($sQuery, $this->iVendorId)) { addmsg("The vendor has been deleted.", "green"); return TRUE; } return FALSE; } } function outputEditor() { echo "
| Vendor Name | ',"\n"; echo '|
| Vendor Url | ',"\n"; echo '