| @@ 180-198 (lines=19) @@ | ||
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | protected function get($var, $tableName = null) |
|
| 181 | { |
|
| 182 | if ($tableName === null) { |
|
| 183 | if (count($this->dbRows) > 1) { |
|
| 184 | throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.'); |
|
| 185 | } elseif (count($this->dbRows) === 1) { |
|
| 186 | $tableName = array_keys($this->dbRows)[0]; |
|
| 187 | } |
|
| 188 | } |
|
| 189 | ||
| 190 | if (!isset($this->dbRows[$tableName])) { |
|
| 191 | if (count($this->dbRows[$tableName] === 0)) { |
|
| 192 | throw new TDBMException('Object is not yet bound to any table.'); |
|
| 193 | } else { |
|
| 194 | throw new TDBMException('Unknown table "'.$tableName.'"" in object.'); |
|
| 195 | } |
|
| 196 | } |
|
| 197 | ||
| 198 | return $this->dbRows[$tableName]->get($var); |
|
| 199 | } |
|
| 200 | ||
| 201 | protected function set($var, $value, $tableName = null) |
|
| @@ 254-272 (lines=19) @@ | ||
| 251 | * |
|
| 252 | * @return AbstractTDBMObject|null |
|
| 253 | */ |
|
| 254 | protected function getRef($foreignKeyName, $tableName = null) |
|
| 255 | { |
|
| 256 | if ($tableName === null) { |
|
| 257 | if (count($this->dbRows) > 1) { |
|
| 258 | throw new TDBMException('This object is based on several tables. You must specify which table you are retrieving data from.'); |
|
| 259 | } elseif (count($this->dbRows) === 1) { |
|
| 260 | $tableName = array_keys($this->dbRows)[0]; |
|
| 261 | } |
|
| 262 | } |
|
| 263 | ||
| 264 | if (!isset($this->dbRows[$tableName])) { |
|
| 265 | if (count($this->dbRows[$tableName] === 0)) { |
|
| 266 | throw new TDBMException('Object is not yet bound to any table.'); |
|
| 267 | } else { |
|
| 268 | throw new TDBMException('Unknown table "'.$tableName.'"" in object.'); |
|
| 269 | } |
|
| 270 | } |
|
| 271 | ||
| 272 | return $this->dbRows[$tableName]->getRef($foreignKeyName); |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|