@@ -118,6 +118,7 @@ private function compileForSelect(Builder $builder, $bindings) {
118118 } else {
119119 $ tables = $ alias ['table ' ];
120120 }
121+ <<<<<<< HEAD
121122
122123 $ queryString = $ this ->queryStringForSelect ($ tables );
123124 $ queryRes = $ this ->getPdo ()->query ($ queryString );
@@ -128,6 +129,32 @@ private function compileForSelect(Builder $builder, $bindings) {
128129 $ tipos [strtolower ($ tables .'. ' .$ row ['name ' ])] = $ row ['type ' ];
129130 if (!empty ($ alias ['alias ' ])) {
130131 $ tipos [strtolower ($ alias ['alias ' ].'. ' .$ row ['name ' ])] = $ row ['type ' ];
132+ =======
133+ $ wheres = [];
134+ foreach ($ builder ->wheres as $ w ){
135+ switch ($ w ['type ' ]){
136+ default :
137+ array_push ($ wheres , $ w );
138+ break ;
139+ case "Nested " :
140+ $ wheres += $ w ['query ' ]->wheres ;
141+ break ;
142+ }
143+ }
144+ $ i = 0 ;
145+ for ($ ind = 0 ; $ ind < count ($ wheres ); $ ind ++ ){
146+ if (isset ($ wheres [$ ind ]['value ' ])){
147+ if (in_array (strtolower ($ tipos [strtolower ($ wheres [$ ind ]['column ' ])]), $ this ->without_quotes )){
148+ if (!is_null ($ bindings [$ i ])){
149+ $ new_binds [$ i ] = $ bindings [$ i ]/1 ;
150+ }else {
151+ $ new_binds [$ i ] = null ;
152+ }
153+ }else {
154+ $ new_binds [$ i ] = (string )$ bindings [$ i ];
155+ }
156+ $ i ++;
157+ >>>>>>> dev
131158 }
132159 }
133160
@@ -345,6 +372,7 @@ private function compileNewQuery($query, $bindings)
345372 }
346373 }
347374 }
375+ <<<<<<< HEAD
348376 }
349377 $ newQuery = str_replace ( "[] " , '' ,$ newQuery );
350378 return $ newQuery ;
@@ -372,6 +400,59 @@ public function compileOffset($offset, $query, $bindings = array(), $me)
372400 } else {
373401 $ res_primaries = $ identity ->column .'+0 AS ' .$ identity ->column ;
374402 $ where_primaries = "#tmpPaginate. " .$ identity ->column .' = #tmpTable. ' .$ identity ->column ;
403+ =======
404+ //Offset operation
405+ $ this ->getPdo ()->query (str_replace (" from " , " into #tmpPaginate from " , $ this ->compileNewQuery ($ query , $ bindings )));
406+ $ this ->getPdo ()->query ("SELECT " .$ res_primaries .", idTmp=identity(18) INTO #tmpTable FROM #tmpPaginate " );
407+ return $ this ->getPdo ()->query ("SELECT #tmpPaginate.*, #tmpTable.idTmp FROM #tmpTable INNER JOIN #tmpPaginate ON " .$ where_primaries ." WHERE #tmpTable.idTmp "
408+ . "BETWEEN " .($ offset +1 ) ." AND " . ($ offset +$ limit )
409+ ." ORDER BY #tmpTable.idTmp ASC " )->fetchAll ($ me ->getFetchMode ());
410+
411+ }
412+ /**
413+ * Run a select statement against the database.
414+ *
415+ * @param string $query
416+ * @param array $bindings
417+ * @param bool $useReadPdo
418+ * @return array
419+ */
420+ public function select ($ query , $ bindings = array (), $ useReadPdo = true )
421+ {
422+ return $ this ->run ($ query , $ bindings , function ($ me , $ query , $ bindings ) use ($ useReadPdo )
423+ {
424+ if ($ me ->pretending ()) return array ();
425+ if ($ this ->queryGrammar ->getBuilder () != NULL ){
426+ $ offset = $ this ->queryGrammar ->getBuilder ()->offset ;
427+ }else {
428+ $ offset = 0 ;
429+ }
430+ if ($ offset >0 ){
431+ return $ this ->compileOffset ($ offset , $ query , $ bindings , $ me );
432+ }else {
433+ $ result = [];
434+ $ statement = $ this ->getPdo ()->query ($ this ->compileNewQuery ($ query , $ bindings ));
435+ do {
436+ $ result += $ statement ->fetchAll ($ me ->getFetchMode ());
437+ } while ($ statement ->nextRowset ());
438+ return $ result ;
439+ }
440+ });
441+ }
442+
443+ /**
444+ * @param string $query
445+ * @param mixed array $bindings
446+ * @return bool
447+ */
448+ public function statement ($ query , $ bindings = array ()) {
449+
450+ return $ this ->run ($ query , $ bindings , function ($ me , $ query , $ bindings )
451+ {
452+ if ($ me ->pretending ()) return true ;
453+ return $ this ->getPdo ()->query ($ this ->compileNewQuery ($ query , $ bindings ));
454+ });
455+ >>>>>>> dev
375456 }
376457
377458 //Offset operation
0 commit comments