| @@ 231-244 (lines=14) @@ | ||
| 228 | * |
|
| 229 | * @return void |
|
| 230 | */ |
|
| 231 | protected function create() |
|
| 232 | { |
|
| 233 | $this->checkDb(); |
|
| 234 | $properties = $this->getProperties(); |
|
| 235 | unset($properties[$this->tableIdColumn]); |
|
| 236 | $columns = array_keys($properties); |
|
| 237 | $values = array_values($properties); |
|
| 238 | ||
| 239 | $this->db->connect() |
|
| 240 | ->insert($this->tableName, $columns) |
|
| 241 | ->execute($values); |
|
| 242 | ||
| 243 | $this->{$this->tableIdColumn} = $this->db->lastInsertId(); |
|
| 244 | } |
|
| 245 | ||
| 246 | ||
| 247 | ||
| @@ 253-266 (lines=14) @@ | ||
| 250 | * |
|
| 251 | * @return void |
|
| 252 | */ |
|
| 253 | protected function update() |
|
| 254 | { |
|
| 255 | $this->checkDb(); |
|
| 256 | $properties = $this->getProperties(); |
|
| 257 | unset($properties[$this->tableIdColumn]); |
|
| 258 | $columns = array_keys($properties); |
|
| 259 | $values = array_values($properties); |
|
| 260 | $values[] = $this->{$this->tableIdColumn}; |
|
| 261 | ||
| 262 | $this->db->connect() |
|
| 263 | ->update($this->tableName, $columns) |
|
| 264 | ->where("{$this->tableIdColumn} = ?") |
|
| 265 | ->execute($values); |
|
| 266 | } |
|
| 267 | ||
| 268 | ||
| 269 | ||