Skip to content

Yii Framework Active Record Behavior that outputs the raw SQL generated by a given Data Provider.

Notifications You must be signed in to change notification settings

evan108108/CTheSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

CTheSQL

Yii Framework Active Record Behavior that outputs the raw SQL generated by a given Data Provider.

If your like me, then you have had occasion to want to see or manipulate the raw SQL generated by a Data Provider. CTheSQL does just that.


Installation

  • Extract of clone to your application.extensions folder

  • Add the following to your main config:

    'import'=>array(..,'ext.CTheSQL.*',) 
  • Add CTheSQL behavior to your desired model(s):

    public function behaviors(){ return array(..,'CTheSQL'=>'ext.CTheSQL.CTheSQL',); }

Usage

Example 1

    $model = new MyModelName('search');
    
    $sql = $model->sql; //Default Data Provider is 'search'
        
	echo $sql;

Example 2

	model = new MyModelName('search');
    
    $model->attributes = $_GET['MyModelName'];
    
    $dataProvider = $model->searchGrid();
    
	$dataProvider->criteria->addCondition('t.status > 0');
    
    $sql = $model->getSql($dataProvider); //optional 2nd param tableAlias default = 't'
  
	echo $sql;

About

Yii Framework Active Record Behavior that outputs the raw SQL generated by a given Data Provider.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages