@@ 171-179 (lines=9) @@ | ||
168 | * @param array $data New ad data |
|
169 | * @return int New advertisement ID |
|
170 | */ |
|
171 | public function insert_ad($data) |
|
172 | { |
|
173 | $data = $this->intersect_ad_data($data); |
|
174 | ||
175 | $sql = 'INSERT INTO ' . $this->ads_table . ' ' . $this->db->sql_build_array('INSERT', $data); |
|
176 | $this->db->sql_query($sql); |
|
177 | ||
178 | return $this->db->sql_nextid(); |
|
179 | } |
|
180 | ||
181 | /** |
|
182 | * Update advertisement |
|
@@ 188-198 (lines=11) @@ | ||
185 | * @param array $data List of data to update in the database |
|
186 | * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
187 | */ |
|
188 | public function update_ad($ad_id, $data) |
|
189 | { |
|
190 | $data = $this->intersect_ad_data($data); |
|
191 | ||
192 | $sql = 'UPDATE ' . $this->ads_table . ' |
|
193 | SET ' . $this->db->sql_build_array('UPDATE', $data) . ' |
|
194 | WHERE ad_id = ' . (int) $ad_id; |
|
195 | $this->db->sql_query($sql); |
|
196 | ||
197 | return $this->db->sql_affectedrows(); |
|
198 | } |
|
199 | ||
200 | /** |
|
201 | * Delete advertisement |