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