@@ 157-170 (lines=14) @@ | ||
154 | * |
|
155 | * @return void |
|
156 | */ |
|
157 | protected function create() |
|
158 | { |
|
159 | $this->checkDb(); |
|
160 | $properties = $this->getProperties(); |
|
161 | unset($properties['id']); |
|
162 | $columns = array_keys($properties); |
|
163 | $values = array_values($properties); |
|
164 | ||
165 | $this->db->connect() |
|
166 | ->insert($this->tableName, $columns) |
|
167 | ->execute($values); |
|
168 | ||
169 | $this->id = $this->db->lastInsertId(); |
|
170 | } |
|
171 | ||
172 | ||
173 | ||
@@ 179-192 (lines=14) @@ | ||
176 | * |
|
177 | * @return void |
|
178 | */ |
|
179 | protected function update() |
|
180 | { |
|
181 | $this->checkDb(); |
|
182 | $properties = $this->getProperties(); |
|
183 | unset($properties['id']); |
|
184 | $columns = array_keys($properties); |
|
185 | $values = array_values($properties); |
|
186 | $values[] = $this->id; |
|
187 | ||
188 | $this->db->connect() |
|
189 | ->update($this->tableName, $columns) |
|
190 | ->where("id = ?") |
|
191 | ->execute($values); |
|
192 | } |
|
193 | ||
194 | ||
195 |