Using conditions inside Sql Data provider

[color="#222222"]I want to use conditions inside SQL data provider query as shown below[/color]

 $count 		=	Yii::$app->db->createCommand('

					SELECT COUNT(*) FROM screen_ticket_booking WHERE id!=:id

					', [':id' => 0])->queryScalar(); 

					$dataProvider = new SqlDataProvider([

					'sql' =>	'SELECT A1.booking_id As Booking_id,

								A3.movie_name As Movie,

								A4.theatre_name As Theatre,

								A1.show_date As Show_date,

								A2.start_time As Time,

								A5.booking_date As Booking_date, As Id



								screen_ticket_booking A1


								LEFT OUTER JOIN screen_show_times A2 ON

								LEFT OUTER JOIN movies A3 ON

								LEFT OUTER JOIN theatres A4 ON

								LEFT OUTER JOIN screen_ticket_booking_history A5 ON A1.booking_id=A5.booking_id


								WHERE !=0 ',

					if( $userid != '1')


					$sql .= ' AND A4.users_backend_id = {$userid}';


					//~ 'params' => [':id'=>$userid],

					'totalCount' => $count,


[color="#222222"]i am getting an error " syntax error, unexpected ‘if’ (T_IF), expecting ‘]’ " . is it not possible to use a condition inside the SQL data provider?[/color]

You cannot use if statement in a PHP array declaration. Try to build the SQL string before the instantiation of SqlDataProvider.

Which code editor/IDE do you use? Any decent one should warn you about PHP syntax errors.

i used geany, and thanks it worked