cthesql Active Record Behavior that outputs the raw SQL generated by a given Data Provider

  1. Requirements
  2. Usage
  3. Installation
  4. Resources

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.

Requirements

Tested on Yii 1.1.11...

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;

Installation

  • Extract or 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',); } 

Resources

CTheSQL on GitHub

3 0
11 followers
339 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: evan108108
Created on: Aug 13, 2012
Last updated: 11 years ago

Downloads

show all

Related Extensions