| @@ 126-139 (lines=14) @@ | ||
| 123 | * |
|
| 124 | * @return void |
|
| 125 | */ |
|
| 126 | private function create() |
|
| 127 | { |
|
| 128 | $db = $this->db; |
|
| 129 | $properties = $this->getProperties(); |
|
| 130 | unset($properties['id']); |
|
| 131 | $columns = array_keys($properties); |
|
| 132 | $values = array_values($properties); |
|
| 133 | ||
| 134 | $db->connect() |
|
| 135 | ->insert($this->tableName, $columns) |
|
| 136 | ->execute($values); |
|
| 137 | ||
| 138 | $this->id = $this->db->lastInsertId(); |
|
| 139 | } |
|
| 140 | ||
| 141 | ||
| 142 | ||
| @@ 150-163 (lines=14) @@ | ||
| 147 | * |
|
| 148 | * @return void |
|
| 149 | */ |
|
| 150 | private function update($values) |
|
| 151 | { |
|
| 152 | $db = $this->db; |
|
| 153 | $properties = $this->getProperties(); |
|
| 154 | unset($properties['id']); |
|
| 155 | $columns = array_keys($properties); |
|
| 156 | $values = array_values($properties); |
|
| 157 | $values[] = $this->id; |
|
| 158 | ||
| 159 | $db->connect() |
|
| 160 | ->update($this->tableName, $columns) |
|
| 161 | ->where("id = ?") |
|
| 162 | ->execute($values); |
|
| 163 | } |
|
| 164 | ||
| 165 | ||
| 166 | ||