| @@ 209-222 (lines=14) @@ | ||
| 206 | * |
|
| 207 | * @return void |
|
| 208 | */ |
|
| 209 | protected function create() |
|
| 210 | { |
|
| 211 | $this->checkDb(); |
|
| 212 | $properties = $this->getProperties(); |
|
| 213 | unset($properties[$this->tableIdColumn]); |
|
| 214 | $columns = array_keys($properties); |
|
| 215 | $values = array_values($properties); |
|
| 216 | ||
| 217 | $this->db->connect() |
|
| 218 | ->insert($this->tableName, $columns) |
|
| 219 | ->execute($values); |
|
| 220 | ||
| 221 | $this->{$this->tableIdColumn} = $this->db->lastInsertId(); |
|
| 222 | } |
|
| 223 | ||
| 224 | ||
| 225 | ||
| @@ 231-244 (lines=14) @@ | ||
| 228 | * |
|
| 229 | * @return void |
|
| 230 | */ |
|
| 231 | protected function update() |
|
| 232 | { |
|
| 233 | $this->checkDb(); |
|
| 234 | $properties = $this->getProperties(); |
|
| 235 | unset($properties[$this->tableIdColumn]); |
|
| 236 | $columns = array_keys($properties); |
|
| 237 | $values = array_values($properties); |
|
| 238 | $values[] = $this->{$this->tableIdColumn}; |
|
| 239 | ||
| 240 | $this->db->connect() |
|
| 241 | ->update($this->tableName, $columns) |
|
| 242 | ->where("{$this->tableIdColumn} = ?") |
|
| 243 | ->execute($values); |
|
| 244 | } |
|
| 245 | ||
| 246 | ||
| 247 | ||