summaryrefslogtreecommitdiffstats
path: root/codebase
diff options
context:
space:
mode:
authorStanislau <stanislau.wolski@gmail.com>2011-11-10 16:33:52 +0300
committerStanislau <stanislau.wolski@gmail.com>2011-11-10 16:33:52 +0300
commit7a79e1d9a75908f8f36c43117dbc1be95ee363fa (patch)
tree916989740fbd53ca7c0a8f2c3128973676929ad4 /codebase
parent8363feeef23aca83cebc8b3a1dcd6802398f5ced (diff)
downloadconnector-php-7a79e1d9a75908f8f36c43117dbc1be95ee363fa.zip
connector-php-7a79e1d9a75908f8f36c43117dbc1be95ee363fa.tar.gz
connector-php-7a79e1d9a75908f8f36c43117dbc1be95ee363fa.tar.bz2
[add] render_complex_sql - renders by sql, preserving it as is
Diffstat (limited to 'codebase')
-rw-r--r--codebase/base_connector.php6
-rw-r--r--codebase/db_common.php9
2 files changed, 13 insertions, 2 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php
index 3203f9b..451c61d 100644
--- a/codebase/base_connector.php
+++ b/codebase/base_connector.php
@@ -387,6 +387,12 @@ class Connector {
$this->request->parse_sql($sql);
return $this->render();
}
+
+ public function render_complex_sql($sql,$id,$fields,$extra=false,$relation_id=false){
+ $this->config->init($id,$fields,$extra,$relation_id);
+ $this->request->parse_sql($sql, true);
+ return $this->render();
+ }
/*! render already configured connector
diff --git a/codebase/db_common.php b/codebase/db_common.php
index 816f332..996feda 100644
--- a/codebase/db_common.php
+++ b/codebase/db_common.php
@@ -215,7 +215,12 @@ class DataRequestConfig{
@param sql
incoming sql string
*/
- public function parse_sql($sql){
+ public function parse_sql($sql, $as_is = false){
+ if ($as_is){
+ $this->fieldset = $sql;
+ return;
+ }
+
$sql= preg_replace("/[ \n\t]+limit[\n\t ,0-9]*$/i","",$sql);
$data = preg_split("/[ \n\t]+\\_from\\_/i",$sql,2);
@@ -224,7 +229,7 @@ class DataRequestConfig{
$this->fieldset = preg_replace("/^[\s]*select/i","",$data[0],1);
//Ignore next type of calls
- //direct call to stored procedure without FROM
+ //direct call to stored procedure without FROM
if ((count($data) == 1) ||
//UNION select
preg_match("#[ \n\r\t]union[ \n\t\r]#i", $sql)){