69 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
70 $this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
71 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
72 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
114 if( $this->AddLimitations ===
'1 = 1' )
116 $this->AddLimitations = $theAddLimitation;
120 throw(
new Exception(
'"AddLimitations" was already set' ) );
123 catch( Exception $e )
157 $Records = $this->Database->select(
158 '* , code AS preview , IF( shows , ( 100 * clicks / shows ) , 0 ) AS ctr' ,
160 "( $this->AddLimitations ) AND $Condition"
163 foreach( $Records as $k => $v )
166 $Records[ $k ] ,
'preview' , $this->Security->get(
get_field( $v ,
'code' ) ,
'unsafe_string' )
172 catch( Exception $e )
216 function select( $Start =
false , $Limit =
false , $Field =
false , $Order =
false ,
217 $Condition =
'1 = 1' )
221 $Condition = $this->DatabaseAlgorithms->select_condition(
222 $Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
227 catch( Exception $e )
259 $Record = $this->SecurityParser->parse_parameters(
260 $Record ,
'campaign_id:integer,allow_not_set,default_0;code:string'
263 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
265 $id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
267 $EventManager =
get_package(
'event_manager' ,
'last' , __FILE__ );
268 $EventManager->trigger_event(
'on_after_create_ad_banner' , array(
'id' => $id ) );
272 catch( Exception $e )
296 function delete( $id )
300 $id = $this->Security->get( $id ,
'integer_list' );
304 $this->Database->delete( $this->NativeTable ,
"( $this->AddLimitations ) AND id IN ( $id )" );
305 $this->Database->commit();
307 catch( Exception $e )
339 $id = $this->Security->get( $id ,
'integer_list' );
341 return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id )" ) );
343 catch( Exception $e )
373 foreach( $Records as $k => $v )
375 $Records[ $k ]->title =
'{lang:ad_code} '.$v->code;
380 catch( Exception $e )
412 $id = $this->Security->get( $id ,
'integer_list' );
413 $Record = $this->SecurityParser->parse_parameters(
414 $Record ,
'campaign_id:integer,default_0;code:string' ,
'allow_not_set'
417 list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
419 if( isset( $Fields[ 0 ] ) )
421 $this->Database->update(
422 $this->NativeTable , $Fields , $Values ,
"( $this->AddLimitations ) AND id IN ( $id )"
424 $this->Database->commit();
427 catch( Exception $e )