@@ 106-114 (lines=9) @@ | ||
103 | * @param array $data New ad data |
|
104 | * @return int New advertisement ID |
|
105 | */ |
|
106 | public function insert_ad($data) |
|
107 | { |
|
108 | $data = $this->intersect_ad_data($data); |
|
109 | ||
110 | $sql = 'INSERT INTO ' . $this->ads_table . ' ' . $this->db->sql_build_array('INSERT', $data); |
|
111 | $this->db->sql_query($sql); |
|
112 | ||
113 | return $this->db->sql_nextid(); |
|
114 | } |
|
115 | ||
116 | /** |
|
117 | * Update advertisement |
|
@@ 123-133 (lines=11) @@ | ||
120 | * @param array $data List of data to update in the database |
|
121 | * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
122 | */ |
|
123 | public function update_ad($ad_id, $data) |
|
124 | { |
|
125 | $data = $this->intersect_ad_data($data); |
|
126 | ||
127 | $sql = 'UPDATE ' . $this->ads_table . ' |
|
128 | SET ' . $this->db->sql_build_array('UPDATE', $data) . ' |
|
129 | WHERE ad_id = ' . (int) $ad_id; |
|
130 | $this->db->sql_query($sql); |
|
131 | ||
132 | return $this->db->sql_affectedrows(); |
|
133 | } |
|
134 | ||
135 | /** |
|
136 | * Delete advertisement |