| @@ 172-185 (lines=14) @@ | ||
| 169 | * |
|
| 170 | * @return void |
|
| 171 | */ |
|
| 172 | protected function create() |
|
| 173 | { |
|
| 174 | $this->checkDb(); |
|
| 175 | $properties = $this->getProperties(); |
|
| 176 | unset($properties['id']); |
|
| 177 | $columns = array_keys($properties); |
|
| 178 | $values = array_values($properties); |
|
| 179 | ||
| 180 | $this->db->connect() |
|
| 181 | ->insert($this->tableName, $columns) |
|
| 182 | ->execute($values); |
|
| 183 | ||
| 184 | $this->id = $this->db->lastInsertId(); |
|
| 185 | } |
|
| 186 | ||
| 187 | ||
| 188 | ||
| @@ 194-207 (lines=14) @@ | ||
| 191 | * |
|
| 192 | * @return void |
|
| 193 | */ |
|
| 194 | protected function update() |
|
| 195 | { |
|
| 196 | $this->checkDb(); |
|
| 197 | $properties = $this->getProperties(); |
|
| 198 | unset($properties['id']); |
|
| 199 | $columns = array_keys($properties); |
|
| 200 | $values = array_values($properties); |
|
| 201 | $values[] = $this->id; |
|
| 202 | ||
| 203 | $this->db->connect() |
|
| 204 | ->update($this->tableName, $columns) |
|
| 205 | ->where("id = ?") |
|
| 206 | ->execute($values); |
|
| 207 | } |
|
| 208 | ||
| 209 | ||
| 210 | ||