cvs: pear(MDB_1) /MDB/MDB Common.php

From: Date: Thu, 16 Oct 2003 11:54:47 +0000
Subject: cvs: pear(MDB_1) /MDB/MDB Common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13658@lists.php.net to get a copy of this message
lsmith Thu Oct 16 07:54:47 2003 EDT Modified files: (Branch: MDB_1) /pear/MDB/MDB Common.php Log: - cosmetic fixes to prepareQuery() - fixed bug in getDSN() incorrect handling of port value - fixed bug in common implementation of currID() which would result in a fatal error Index: pear/MDB/MDB/Common.php diff -u pear/MDB/MDB/Common.php:1.114.4.1 pear/MDB/MDB/Common.php:1.114.4.2 --- pear/MDB/MDB/Common.php:1.114.4.1 Thu Sep 18 13:32:17 2003 +++ pear/MDB/MDB/Common.php Thu Oct 16 07:54:47 2003 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.114.4.1 2003/09/18 17:32:17 lsmith Exp $ +// $Id: Common.php,v 1.114.4.2 2003/10/16 11:54:47 lsmith Exp $ /** * @package MDB @@ -885,7 +885,7 @@ default: $dsn = $this->phptype.'://'.$this->user.':' .$this->password.'@'.$this->host - .(isset($this->port) ? (':'.$this->port) : '') + .($this->port ? (':'.$this->port) : '') .'/'.$this->database_name; break; } @@ -1762,9 +1762,12 @@ $this->debug("PrepareQuery: $query"); $positions = array(); for($position = 0; - $position < strlen($query) && gettype($question = strpos($query, '?', $position)) == 'integer';) { - if (gettype($quote = strpos($query, "'", $position)) == 'integer' && $quote < $question) { - if (gettype($end_quote = strpos($query, "'", $quote + 1)) != 'integer') { + $position < strlen($query) && is_integer($question = strpos($query, '?', $position)); + ) { + if (is_integer($quote = strpos($query, "'", $position)) + && $quote < $question + ) { + if (!is_integer($end_quote = strpos($query, "'", $quote + 1))) { return($this->raiseError(MDB_ERROR_SYNTAX, NULL, NULL, 'Prepare query: query with an unterminated text string specified')); } @@ -1790,7 +1793,8 @@ $position = $question + 1; } } - $this->prepared_queries[] = array('Query' => $query, + $this->prepared_queries[] = array( + 'Query' => $query, 'Positions' => $positions, 'Values' => array(), 'Types' => array() @@ -1886,7 +1890,10 @@ return($result); } $index = $prepared_query-1; - for($this->clobs[$prepared_query] = $this->blobs[$prepared_query] = array(), $query = '', $last_position = $position = 0; + $success = MDB_OK; + $this->clobs[$prepared_query] = $this->blobs[$prepared_query] = array(); + $query = ''; + for($last_position = $position = 0; $position < count($this->prepared_queries[$index]['Positions']); $position++) { if (!isset($this->prepared_queries[$index]['Values'][$position])) { @@ -1919,13 +1926,15 @@ } $last_position = $current_position + 1; } - if (!isset($success) || !MDB::isError($success)) { + if (!MDB::isError($success)) { $query .= substr($this->prepared_queries[$index]['Query'], $last_position); if ($this->selected_row_limit > 0) { $this->prepared_queries[$index]['First'] = $this->first_selected_row; $this->prepared_queries[$index]['Limit'] = $this->selected_row_limit; } - if (isset($this->prepared_queries[$index]['Limit']) && $this->prepared_queries[$index]['Limit'] > 0) { + if (isset($this->prepared_queries[$index]['Limit']) + && $this->prepared_queries[$index]['Limit'] > 0 + ) { $this->first_selected_row = $this->prepared_queries[$index]['First']; $this->selected_row_limit = $this->prepared_queries[$index]['Limit']; } else { @@ -3472,6 +3481,10 @@ */ function getValue($type, $value) { + if (empty($type)) { + return($this->raiseError(MDB_ERROR_SYNTAX, NULL, NULL, + 'getValue: called without type to convert to')); + } if (method_exists($this,"get{$type}Value")) { return $this->{"get{$type}Value"}($value); } @@ -3543,9 +3556,9 @@ { $this->warnings[] = 'database does not support getting current sequence value, the sequence value was incremented'; - expectError(MDB_ERROR_NOT_CAPABLE); + $this->expectError(MDB_ERROR_NOT_CAPABLE); $id = $this->nextId($seq_name); - popExpectError(MDB_ERROR_NOT_CAPABLE); + $this->popExpectError(MDB_ERROR_NOT_CAPABLE); if (MDB::isError($id)) { if ($id->getCode() == MDB_ERROR_NOT_CAPABLE) { return($this->raiseError(MDB_ERROR_NOT_CAPABLE, NULL, NULL,

« previous php.pear.cvs (#13658) next »