* @param $sql String
* @param $columns Array
*/
- public function __construct( $db, $result, $num_rows, $sql, $columns ){
+ public function __construct( $db, $result, $num_rows, $sql, $columns ) {
$this->db = $db;
- if( $result instanceof ResultWrapper ){
+ if( $result instanceof ResultWrapper ) {
$this->result = $result->result;
- }
- else{
+ } else {
$this->result = $result;
}
* @return mixed Array on success, false on failure
* @throws DBUnexpectedError
*/
- public function fetchRow(){
+ public function fetchRow() {
if ( $this->result
&& $this->num_rows > 0
&& $this->current_pos >= 0
}
}
- if ( $this->loadedLines > $this->current_pos ){
+ if ( $this->loadedLines > $this->current_pos ) {
return $this->resultSet[$this->current_pos++];
}
* Free a DB2 result object
* @throws DBUnexpectedError
*/
- public function freeResult(){
+ public function freeResult() {
unset( $this->resultSet );
if ( !@db2_free_result( $this->result ) ) {
throw new DBUnexpectedError( $this, "Unable to free DB2 result\n" );
* Returns the database connection object
* @return Object
*/
- public function getDb(){
+ public function getDb() {
return $this->mConn;
}
// Wide characters are evil -- some of them look like '
$s = utf8_encode( $s );
// Fix its stupidity
- $from = array( "\\\\", "\\'", '\\n', '\\t', '\\"', '\\r' );
- $to = array( "\\", "''", "\n", "\t", '"', "\r" );
+ $from = array( "\\\\", "\\'", '\\n', '\\t', '\\"', '\\r' );
+ $to = array( "\\", "''", "\n", "\t", '"', "\r" );
$s = str_replace( $from, $to, $s ); // DB2 expects '', not \' escaping
return $s;
}
// find out the primary keys
$keyres = $this->doQuery( "SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = '"
- . strtoupper( $table )
- . "' AND TBCREATOR = '"
- . strtoupper( $schema )
- . "' AND KEYSEQ > 0" );
+ . strtoupper( $table )
+ . "' AND TBCREATOR = '"
+ . strtoupper( $schema )
+ . "' AND KEYSEQ > 0" );
$keys = array();
for (
* @param array|string $conds
* @param string $fname
* @throws DBUnexpectedError
- * @return bool|\ResultWrapper
+ * @return bool|ResultWrapper
*/
public function delete( $table, $conds, $fname = 'DatabaseIbm_db2::delete' ) {
if ( !$conds ) {
}
}
- if ( isset( $options['GROUP BY'] ) ) {
- $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
- }
- if ( isset( $options['HAVING'] ) ) {
- $preLimitTail .= " HAVING {$options['HAVING']}";
- }
- if ( isset( $options['ORDER BY'] ) ) {
- $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
- }
+ $preLimitTail .= $this->makeGroupByWithHaving( $options );
+
+ $preLimitTail .= $this->makeOrderBy( $options );
if ( isset( $noKeyOptions['DISTINCT'] )
|| isset( $noKeyOptions['DISTINCTROW'] ) )