3 * A set of data storeable in databases
5 * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.ship-simu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
29 private $tableName = '';
34 private $uniqueKey = '';
39 private $primaryKey = '';
42 * Protected constructor
46 protected function __construct () {
47 // Call parent constructor
48 parent::__construct(__CLASS__);
52 * Creates an instance of this criteria
54 * @param $tableName Name of the table
55 * @return $criteriaInstance An instance of this criteria
57 public static final function createDataSetCriteria ($tableName) {
59 $criteriaInstance = new DataSetCriteria();
62 $criteriaInstance->setTableName($tableName);
64 // Return the instance
65 return $criteriaInstance;
69 * Setter for table name
71 * @param $tableName Name of the table to set
74 public final function setTableName ($tableName) {
75 $this->tableName = (string) $tableName;
79 * Getter for table name
81 * @return $tableName Name of the table to set
83 public final function getTableName () {
84 return $this->tableName;
88 * Setter for unique key
90 * @param $uniqueKey Column to use as unique key
93 public final function setUniqueKey ($uniqueKey) {
94 $this->uniqueKey = (string) $uniqueKey;
98 * Getter for unique key
100 * @return $uniqueKey Column to use as unique key
102 public final function getUniqueKey () {
103 return $this->uniqueKey;
107 * Getter for unique key value
109 * @return $uniqueValue Value of the unique key
111 public final function getUniqueValue () {
112 return $this->getCriteriaElemnent($this->getUniqueKey());
116 * Getter for primary key or unique key if not set
118 * @return $primaryKey Primary key or unique key if not set
120 public final function getPrimaryKey () {
121 // Get primary key by default
122 $primaryKey = $this->primaryKey;
124 if (empty($primaryKey)) {
126 $primaryKey = $this->getUniqueKey();
134 * Setter for primary key
136 * @param $primaryKey Primary key to set
139 public final function setPrimaryKey ($primaryKey) {
140 $this->primaryKey = (string) $primaryKey;