Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created June 7, 2013 18:37
Show Gist options
  • Save mishudark/5731402 to your computer and use it in GitHub Desktop.
Save mishudark/5731402 to your computer and use it in GitHub Desktop.
Get SQL from FIND model
diff --git a/core/lib/Cake/Model/Datasource/DboSource.php b/core/lib/Cake/Model/Datasource/DboSource.php
index 57368b4..f17a658 100755
--- a/core/lib/Cake/Model/Datasource/DboSource.php
+++ b/core/lib/Cake/Model/Datasource/DboSource.php
@@ -1026,7 +1026,7 @@ class DboSource extends DataSource {
* @param integer $recursive Number of levels of association
* @return mixed boolean false on error/failure. An array of results on success.
*/
- public function read(Model $model, $queryData = array(), $recursive = null) {
+ public function read(Model $model, $queryData = array(), $recursive = null, $sql = null) {
$queryData = $this->_scrubQueryData($queryData);
$null = null;
@@ -1076,6 +1076,7 @@ class DboSource extends DataSource {
}
$query = trim($this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null));
+ if($sql) return $query;
$resultSet = $this->fetchAll($query, $model->cacheQueries);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment