@@ 217-236 (lines=20) @@ | ||
214 | return $this->dbRows[$tableName]->has($var); |
|
215 | } |
|
216 | ||
217 | public function set($var, $value, $tableName = null) { |
|
218 | if ($tableName === null) { |
|
219 | if (count($this->dbRows) > 1) { |
|
220 | throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.'); |
|
221 | } elseif (count($this->dbRows) === 1) { |
|
222 | $tableName = array_keys($this->dbRows)[0]; |
|
223 | } else { |
|
224 | throw new TDBMException("Please specify a table for this object."); |
|
225 | } |
|
226 | } |
|
227 | ||
228 | if (!isset($this->dbRows[$tableName])) { |
|
229 | $this->registerTable($tableName); |
|
230 | } |
|
231 | ||
232 | $this->dbRows[$tableName]->set($var, $value); |
|
233 | if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) { |
|
234 | $this->status = TDBMObjectStateEnum::STATE_DIRTY; |
|
235 | } |
|
236 | } |
|
237 | ||
238 | /** |
|
239 | * @param string $foreignKeyName |
|
@@ 242-261 (lines=20) @@ | ||
239 | * @param string $foreignKeyName |
|
240 | * @param AbstractTDBMObject $bean |
|
241 | */ |
|
242 | public function setRef($foreignKeyName, AbstractTDBMObject $bean, $tableName = null) { |
|
243 | if ($tableName === null) { |
|
244 | if (count($this->dbRows) > 1) { |
|
245 | throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.'); |
|
246 | } elseif (count($this->dbRows) === 1) { |
|
247 | $tableName = array_keys($this->dbRows)[0]; |
|
248 | } else { |
|
249 | throw new TDBMException("Please specify a table for this object."); |
|
250 | } |
|
251 | } |
|
252 | ||
253 | if (!isset($this->dbRows[$tableName])) { |
|
254 | $this->registerTable($tableName); |
|
255 | } |
|
256 | ||
257 | $this->dbRows[$tableName]->setRef($foreignKeyName, $bean); |
|
258 | if ($this->dbRows[$tableName]->_getStatus() === TDBMObjectStateEnum::STATE_DIRTY) { |
|
259 | $this->status = TDBMObjectStateEnum::STATE_DIRTY; |
|
260 | } |
|
261 | } |
|
262 | ||
263 | /** |
|
264 | * @param string $foreignKeyName A unique name for this reference |