appdb/include vendor.php
WineHQ
wineowner at wine.codeweavers.com
Sat May 12 11:54:58 CDT 2007
ChangeSet ID: 31128
CVSROOT: /opt/cvs-commit
Module name: appdb
Changes by: wineowner at winehq.org 2007/05/12 11:54:58
Modified files:
include : vendor.php
Log message:
Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Don't create duplicate vendors. If there is a vendor with the same name as the one being
created retrieve the duplicate vendors information for the current object and return TRUE,
even though we didn't really create new vendor we can handle this error situation more
gracefully than returning false.
Patch: http://cvs.winehq.org/patch.py?id=31128
Old revision New revision Changes Path
1.27 1.28 +20 -0 appdb/include/vendor.php
Index: appdb/include/vendor.php
diff -u -p appdb/include/vendor.php:1.27 appdb/include/vendor.php:1.28
--- appdb/include/vendor.php:1.27 12 May 2007 16:54:58 -0000
+++ appdb/include/vendor.php 12 May 2007 16:54:58 -0000
@@ -60,9 +60,29 @@ class Vendor {
/**
* Creates a new vendor.
+ *
+ * NOTE: If creating a vendor with the same name as an existing vendor
+ * we retrieve the existing vendors information and return true,
+ * even though we didn't create the vendor, this makes it easier
+ * for the user of the vendor class.
*/
function create()
{
+ /* Check for duplicates */
+ $hResult = query_parameters("SELECT * FROM vendor WHERE vendorName = '?'",
+ $this->sName);
+ if($hResult && $oRow = mysql_fetch_object($hResult))
+ {
+ if(mysql_num_rows($hResult))
+ {
+ $this->vendor($oRow->vendorId);
+
+ /* Even though we did not create a new vendor, the caller is provided
+ with an id and can proceed as normal, so we return TRUE */
+ return TRUE;
+ }
+ }
+
$hResult = query_parameters("INSERT INTO vendor (vendorName, vendorURL, queued) ".
"VALUES ('?', '?', '?')",
$this->sName, $this->sWebpage,
More information about the wine-cvs
mailing list