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