problem of quotes double quotes in SQL request

I have 3 tables linked like it

it_system ( IT_SYSTEM_ID)

release1 (IT_SYSTEM_ID, TECHNICAL_COMPONENT_, RELEASE1)

technical_component (TECHNICAL_COMPONENT_)

it_system<–0,n----------release1----------0,n–>technical_component

I have an it_system view showing a technical_component subform that works well

but now I would like a to show the RELEASE1 variable, think my sql is correct, the only problem i have is a problem of quotes and double quotes, I don’t know how to do with them in this case (it does not work but not so far, here , the proble of quotes is for the variable $model->IT_SYSTEM_ID tried 1000000 solutions but no results…

here is my it_system/view


$this->widget('zii.widgets.grid.CGridView', array(

    'id'=>'child-grid',

    'dataProvider'=>$technical_componentRecords,

    'columns'=>array(

		'TECHNICAL_COMPONENT_',

		array(

			'name'=>'Release',

			'value'=>

			'	

				Release1::model()->findBySql(

				"

					SELECT release1.RELEASE1 

					FROM release1, it_system , technical_component

					WHERE release1.IT_SYSTEM_ID= 

					\'"$model->IT_SYSTEM_ID"\'

					AND release1.TECHNICAL_COMPONENT_=

					\'

						$data->TECHNICAL_COMPONENT_

					\'

				"

				)->RELEASE1

			'

		),

	),  				

));



Yes you have a big problem, no only for quotes: please read a little bit more on yii and its data providers. Use the framework ! :slight_smile:

i suppose you have:




class Release1 extends CActiveRecord() {


    public $IT_SYSTEM_ID;

	public $TECHNICAL_COMPONENT_;


	// create a data provider for your grid or list or anything you want

	//	

	public function getDataProvider($Filter_by_IT_SYSTEM_ID, $Filtered_by_TECHNICAL_COMPONENT_) {

		

		$where = "IT_SYSTEM_ID = '".$Filter_by_IT_SYSTEM_ID."'  and  TECHNICAL_COMPONENT_='".$Filtered_by_TECHNICAL_COMPONENT_."'";


		return new CActiveDataProvider(self::model(), array(

	    	'criteria'=>array(

	       		'condition'=>$where,

	    	),

	    	'pagination'=>array(

	        	'pageSize'=>20,

	    	),

		));		

	}	

}

Next in your view:




$this->widget('zii.widgets.grid.CGridView', array(

    'id'=>'child-grid',

    'dataProvider'=>$model->getDataProvider("Your IT_SYSTEM_ID","Your Component key"),

    'columns'=>array('TECHNICAL_COMPONENT_','IT_SYSTEM_ID'),

));

I want to show the release1 and the result of the technical_component this exemple is set to show just release1 table results , thing i have already done

Please do you have a solution for the quotes problems? i have to do the request in the grid view because i need the variable $data.

Probably the following will work:




	'value'=>

	'	

		Release1::model()->findBySql(

		"

			SELECT release1.RELEASE1 

			FROM release1, it_system , technical_component

			WHERE release1.IT_SYSTEM_ID= \'' . $model->IT_SYSTEM_ID . '\'

			AND release1.TECHNICAL_COMPONENT_= \'$data->TECHNICAL_COMPONENT_\'

		"

		)->RELEASE1

	'	



But I would rather second bluyell.

I’m afraid you are loosing much of the benefit of using Yii and its AR …

Thank you softark it works :) .No worries, i will try with yii , but first i want a working result ^^

Sorry, but i think resolving "your quotes" is a extremally bad way to do that and is a contribution to make things in the wrong way bypassing the framework…the way i present for you is using the YII WAY…using the framework. You must extend this example to feet your needs If you look deeply in your code: you are by passing the CActiveRecord model.

As @softark said, resolve your issue by using the provided example (post #4), but learn more in yii and you’ll discover the benefits of Yii.

byebye !