Go to the documentation of this file.00001 <?php
00002
00003 include_once 'maxdbResultset.php';
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 class maxdbStatement
00018 {
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 private $objConnection;
00030
00031
00032
00033
00034
00035
00036
00037 private $objLimit = false;
00038
00039
00040
00041
00042
00043
00044
00045 private $objOffset = false;
00046
00047
00048
00049
00050
00051
00052
00053 private $objParameters = array();
00054
00055
00056
00057
00058
00059
00060
00061 private $objSequence = false;
00062
00063
00064
00065
00066
00067
00068
00069 private $objQuery;
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 function __construct( $query, $connection )
00083 {
00084 $this->objConnection = $connection;
00085 $this->objQuery = $query;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095 function bind( $param, $no_quotes=false )
00096 {
00097
00098 if ( ( is_string( $param ) && !is_numeric( $param ) ) && !$no_quotes )
00099 {
00100 if ( get_magic_quotes_gpc() )
00101 {
00102 $param = stripslashes( $param );
00103 $param = "'" . maxdb_real_escape_string( $this->objConnection->connection(), $param ) . "'";
00104 }
00105 else
00106 {
00107 $param = "'" . maxdb_real_escape_string( $this->objConnection->connection(), $param ) . "'";
00108 }
00109 }
00110
00111 $this->objParameters[] = $param;
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 function execute()
00121 {
00122 $objResult = maxdb_query( $this->objConnection->connection(), $this->objPrepareSQL() )
00123 or trigger_error( maxdb_error( $this->objConnection->connection() ), E_USER_WARNING );
00124
00125 return new maxdbResultset( $objResult, $this->objConnection->connection() );
00126 }
00127
00128
00129
00130
00131
00132
00133
00134 public function limit( $limit )
00135 {
00136
00137 $this->objLimit = ( is_numeric( $limit ) && $limit > 0 ) ? ( int )$limit : 1;
00138 }
00139
00140
00141
00142
00143
00144
00145
00146 public function objExecuteNonPrepared()
00147 {
00148 $objResult = maxdb_query( $this->objConnection->connection(), $this->objQuery )
00149 or trigger_error( maxdb_error( $this->objConnection->connection() ), E_USER_WARNING );
00150
00151 return new maxdbResultset( $objResult, $this->objConnection->connection() );
00152 }
00153
00154
00155
00156
00157
00158
00159
00160 private function objPrepareSQL()
00161 {
00162 $objSqlParts = explode( '?', $this->objQuery );
00163 $objQuery = $objSqlParts[0];
00164
00165 for ( $i = 1; $i < count( $objSqlParts ); $i++ )
00166 $objQuery .= $this->objParameters[$i - 1] . $objSqlParts[$i];
00167
00168 $objQuery = ( $this->objLimit ) ? str_ireplace( ':limit', $this->objLimit, $objQuery ) : $objQuery;
00169 $objQuery = ( $this->objOffset ) ? str_ireplace( ':offset', $this->objOffset, $objQuery ) : $objQuery;
00170 $objQuery = ( $this->objSequence ) ? str_ireplace( ':seq', $this->objSequence, $objQuery ) : $objQuery;
00171
00172 return $objQuery;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181 public function offset( $offset )
00182 {
00183
00184 $this->objOffset = ( is_numeric( $offset ) && $offset > 0 ) ? ( int )$offset : 1;
00185 }
00186
00187
00188
00189
00190
00191
00192
00193 public function sequence( $sequence )
00194 {
00195 $this->objSequence = $sequence . '.NEXTVAL';
00196 }
00197 }
00198
00199 ?>