@@ -250,8 +250,9 @@ public function contains($field_name, $value)
250
250
public function delete ()
251
251
{
252
252
$ this ->is_dirty = true ;
253
+ $ this ->buildQuery (MONTY_QUERY_DELETE );
253
254
254
- return $ this ->buildQuery ( MONTY_QUERY_DELETE );
255
+ return $ this ->query ( );
255
256
}
256
257
257
258
/**
@@ -331,8 +332,7 @@ protected function buildQuery($type = MONTY_QUERY_SELECT)
331
332
break ;
332
333
}
333
334
$ this ->is_dirty = false ;
334
-
335
- return $ this ->query ($ query_string );
335
+ $ this ->query_string = $ query_string ;
336
336
}
337
337
338
338
/**
@@ -511,13 +511,16 @@ protected function buildQueryLimit($type)
511
511
/**
512
512
* Monty_MySQLI_Easy::query()
513
513
*
514
- * @param string $query_string The SQL query to execute
514
+ * @param string $query_string optional The SQL query to execute
515
515
*
516
516
* @return bool $boolHasSucceeded
517
517
*/
518
- public function query ($ query_string )
518
+ public function query ($ query_string = null )
519
519
{
520
520
$ this ->is_dirty = false ;
521
+ if ($ query_string === null ) {
522
+ $ query_string = $ this ->query_string ;
523
+ }
521
524
if (!parent ::query ($ query_string )) {
522
525
trigger_error ($ this ->error (), E_USER_ERROR );
523
526
@@ -602,6 +605,7 @@ public function limit()
602
605
public function next ($ type = null )
603
606
{
604
607
$ this ->buildQuery ();
608
+ $ this ->query ();
605
609
606
610
return parent ::next ($ type );
607
611
}
@@ -616,6 +620,7 @@ public function next($type = null)
616
620
public function nextfield ($ field_data = 0 )
617
621
{
618
622
$ this ->buildQuery ();
623
+ $ this ->query ();
619
624
620
625
return parent ::nextfield ($ field_data );
621
626
}
@@ -631,6 +636,7 @@ public function nextfield($field_data = 0)
631
636
public function queryall ($ query_string , $ type = null )
632
637
{
633
638
$ this ->query ($ query_string );
639
+
634
640
return $ this ->all ($ type );
635
641
}
636
642
@@ -644,6 +650,7 @@ public function queryall($query_string, $type = null)
644
650
public function all ($ type = null )
645
651
{
646
652
$ this ->buildQuery ();
653
+ $ this ->query ();
647
654
648
655
return parent ::all ($ type );
649
656
}
@@ -685,7 +692,8 @@ public function insert($fields_list, $type = MONTY_INSERT_NORMAL)
685
692
$ this ->is_dirty = true ;
686
693
$ this ->insert_type = $ type ;
687
694
688
- return $ this ->buildQuery (MONTY_QUERY_INSERT );
695
+ $ this ->buildQuery (MONTY_QUERY_INSERT );
696
+ return $ this ->query ();
689
697
}
690
698
691
699
/**
@@ -696,6 +704,7 @@ public function insert($fields_list, $type = MONTY_INSERT_NORMAL)
696
704
public function rows ()
697
705
{
698
706
$ this ->buildQuery ();
707
+ $ this ->query ();
699
708
700
709
return parent ::rows ();
701
710
}
@@ -710,6 +719,7 @@ public function rows()
710
719
public function seek ($ row_number )
711
720
{
712
721
$ this ->buildQuery ();
722
+ $ this ->query ();
713
723
714
724
return parent ::seek ($ row_number );
715
725
}
@@ -731,12 +741,16 @@ public function sort($by, $is_asc = 1)
731
741
/**
732
742
* Monty_MySQLI_Easy::sql()
733
743
*
734
- * @param int $type The query type
744
+ * @param int $type optional The query type
745
+ * @param int $insert_type optional INSERT type
735
746
*
736
747
* @return string $query_string
737
748
*/
738
- public function sql ($ type = MONTY_QUERY_SELECT )
749
+ public function sql ($ type = MONTY_QUERY_SELECT , $ insert_type = MONTY_INSERT_NORMAL )
739
750
{
751
+ if ($ type === MONTY_QUERY_INSERT ) {
752
+ $ this ->insert_type = $ insert_type ;
753
+ }
740
754
$ this ->buildQuery ($ type );
741
755
742
756
return $ this ->query_string ;
@@ -764,7 +778,8 @@ public function truncate()
764
778
{
765
779
$ this ->is_dirty = true ;
766
780
767
- return $ this ->buildQuery (MONTY_QUERY_TRUNCATE );
781
+ $ this ->buildQuery (MONTY_QUERY_TRUNCATE );
782
+ return $ this ->query ();
768
783
}
769
784
770
785
/**
@@ -783,6 +798,7 @@ public function update($fields_list, $value = null)
783
798
$ this ->fields_list = $ fields_list ;
784
799
$ this ->is_dirty = true ;
785
800
786
- return $ this ->buildQuery (MONTY_QUERY_UPDATE );
801
+ $ this ->buildQuery (MONTY_QUERY_UPDATE );
802
+ return $ this ->query ();
787
803
}
788
804
}
0 commit comments