|
@@ 157-165 (lines=9) @@
|
| 154 |
|
* @param array $data New ad data |
| 155 |
|
* @return int New advertisement ID |
| 156 |
|
*/ |
| 157 |
|
public function insert_ad($data) |
| 158 |
|
{ |
| 159 |
|
$data = $this->intersect_ad_data($data); |
| 160 |
|
|
| 161 |
|
$sql = 'INSERT INTO ' . $this->ads_table . ' ' . $this->db->sql_build_array('INSERT', $data); |
| 162 |
|
$this->db->sql_query($sql); |
| 163 |
|
|
| 164 |
|
return $this->db->sql_nextid(); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
/** |
| 168 |
|
* Update advertisement |
|
@@ 174-184 (lines=11) @@
|
| 171 |
|
* @param array $data List of data to update in the database |
| 172 |
|
* @return int Number of affected rows. Can be used to determine if any ad has been updated. |
| 173 |
|
*/ |
| 174 |
|
public function update_ad($ad_id, $data) |
| 175 |
|
{ |
| 176 |
|
$data = $this->intersect_ad_data($data); |
| 177 |
|
|
| 178 |
|
$sql = 'UPDATE ' . $this->ads_table . ' |
| 179 |
|
SET ' . $this->db->sql_build_array('UPDATE', $data) . ' |
| 180 |
|
WHERE ad_id = ' . (int) $ad_id; |
| 181 |
|
$this->db->sql_query($sql); |
| 182 |
|
|
| 183 |
|
return $this->db->sql_affectedrows(); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
/** |
| 187 |
|
* Delete advertisement |