@@ -60,7 +60,7 @@ public function get_ad($ad_id)
60
60
$ data = $ this ->db ->sql_fetchrow ($ result );
61
61
$ this ->db ->sql_freeresult ($ result );
62
62
63
- return $ data !== false ? $ data : array () ;
63
+ return $ data !== false ? $ data : [] ;
64
64
}
65
65
66
66
/**
@@ -183,8 +183,8 @@ public function increment_ad_clicks($ad_id)
183
183
/**
184
184
* Insert new advertisement to the database
185
185
*
186
- * @param array $data New ad data
187
- * @return int New advertisement ID
186
+ * @param array $data New ad data
187
+ * @return int New advertisement ID
188
188
*/
189
189
public function insert_ad ($ data )
190
190
{
@@ -195,7 +195,7 @@ public function insert_ad($data)
195
195
// add a row to ads table
196
196
$ sql = 'INSERT INTO ' . $ this ->ads_table . ' ' . $ this ->db ->sql_build_array ('INSERT ' , $ data );
197
197
$ this ->db ->sql_query ($ sql );
198
- $ ad_id = $ this ->db ->sql_nextid ();
198
+ $ ad_id = ( int ) $ this ->db ->sql_nextid ();
199
199
200
200
$ this ->insert_ad_group_data ($ ad_id , $ ad_groups );
201
201
@@ -212,7 +212,7 @@ public function insert_ad($data)
212
212
public function update_ad ($ ad_id , $ data )
213
213
{
214
214
// extract ad groups here because it gets filtered in intersect_ad_data()
215
- $ ad_groups = isset ( $ data ['ad_groups ' ]) ? $ data [ ' ad_groups ' ] : array () ;
215
+ $ ad_groups = $ data ['ad_groups ' ] ?? [] ;
216
216
$ data = $ this ->intersect_ad_data ($ data );
217
217
218
218
$ sql = 'UPDATE ' . $ this ->ads_table . '
@@ -269,7 +269,7 @@ public function remove_ad_owner(array $user_ids)
269
269
*/
270
270
public function get_ad_locations ($ ad_id )
271
271
{
272
- $ ad_locations = array () ;
272
+ $ ad_locations = [] ;
273
273
274
274
$ sql = 'SELECT location_id
275
275
FROM ' . $ this ->ad_locations_table . '
@@ -293,13 +293,13 @@ public function get_ad_locations($ad_id)
293
293
*/
294
294
public function insert_ad_locations ($ ad_id , $ ad_locations )
295
295
{
296
- $ sql_ary = array () ;
296
+ $ sql_ary = [] ;
297
297
foreach ($ ad_locations as $ ad_location )
298
298
{
299
- $ sql_ary [] = array (
299
+ $ sql_ary [] = [
300
300
'ad_id ' => $ ad_id ,
301
301
'location_id ' => $ ad_location ,
302
- ) ;
302
+ ] ;
303
303
}
304
304
$ this ->db ->sql_multi_insert ($ this ->ad_locations_table , $ sql_ary );
305
305
}
@@ -325,7 +325,7 @@ public function delete_ad_locations($ad_id)
325
325
*/
326
326
public function load_memberships ($ user_id )
327
327
{
328
- $ memberships = array () ;
328
+ $ memberships = [] ;
329
329
$ sql = 'SELECT group_id
330
330
FROM ' . USER_GROUP_TABLE . '
331
331
WHERE user_id = ' . (int ) $ user_id . '
@@ -371,7 +371,7 @@ public function load_groups($ad_id)
371
371
*/
372
372
protected function intersect_ad_data ($ data )
373
373
{
374
- return array_intersect_key ($ data , array (
374
+ return array_intersect_key ($ data , [
375
375
'ad_name ' => '' ,
376
376
'ad_note ' => '' ,
377
377
'ad_code ' => '' ,
@@ -384,7 +384,7 @@ protected function intersect_ad_data($data)
384
384
'ad_owner ' => '' ,
385
385
'ad_content_only ' => '' ,
386
386
'ad_centering ' => '' ,
387
- ) );
387
+ ] );
388
388
}
389
389
390
390
/**
@@ -428,13 +428,13 @@ protected function sql_random()
428
428
*/
429
429
protected function insert_ad_group_data ($ ad_id , $ ad_groups )
430
430
{
431
- $ sql_ary = array () ;
431
+ $ sql_ary = [] ;
432
432
foreach ($ ad_groups as $ group )
433
433
{
434
- $ sql_ary [] = array (
434
+ $ sql_ary [] = [
435
435
'ad_id ' => $ ad_id ,
436
436
'group_id ' => $ group ,
437
- ) ;
437
+ ] ;
438
438
}
439
439
$ this ->db ->sql_multi_insert ($ this ->ad_group_table , $ sql_ary );
440
440
}
0 commit comments