Code syncronized with shipsimu code base
[mailer.git] / inc / classes / main / criteria / class_DataSetCriteria.php
index 2e76c2f94d518ac66873823e0ac8ad525feda36c..34715c52a9b784d3c97f6d8f1c2f7ce37cabe4f2 100644 (file)
@@ -5,7 +5,7 @@
  * @see                        DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -38,6 +38,11 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
         */
        private $uniqueKey = "";
 
+       /**
+        * Primary key
+        */
+       private $primaryKey = "";
+
        /**
         * Protected constructor
         *
@@ -47,12 +52,6 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Storeable data set for databases");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -61,12 +60,16 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
        /**
         * Creates an instance of this criteria
         *
-        * @return $criteriaInstance    An instance of this criteria
+        * @param       $tableName                      Name of the table
+        * @return      $criteriaInstance       An instance of this criteria
         */
-       public final static function createDataSetCriteria () {
+       public final static function createDataSetCriteria ($tableName) {
                // Get a new instance
                $criteriaInstance = new DataSetCriteria();
 
+               // Set table name
+               $criteriaInstance->setTableName($tableName);
+
                // Return the instance
                return $criteriaInstance;
        }
@@ -150,6 +153,34 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
        public final function getCriteriaArray () {
                return $this->tableColumns;
        }
+
+       /**
+        * Getter for primary key or unique key if not set
+        *
+        * @return      $primaryKey             Primary key or unique key if not set
+        */
+       public final function getPrimaryKey () {
+               // Get primary key by default
+               $primaryKey = $this->primaryKey;
+
+               if (empty($primaryKey)) {
+                       // Get uniqueKey
+                       $primaryKey = $this->getUniqueKey();
+               } // END - if
+
+               // Return it
+               return $primaryKey;
+       }
+
+       /**
+        * Setter for primary key
+        *
+        * @param       $primaryKey             Primary key to set
+        * @return      void
+        */
+       public final function setPrimaryKey ($primaryKey) {
+               $this->primaryKey = (string) $primaryKey;
+       }
 }
 
 // [EOF]