Changeset 1404
- Timestamp:
- 06/09/06 14:35:29 (2 years ago)
- Files:
-
- trunk/lib/vendor/creole/Creole.php (modified) (1 diff)
- trunk/lib/vendor/creole/common/PreparedStatementCommon.php (modified) (3 diffs)
- trunk/lib/vendor/creole/drivers/mysqli/metadata/MySQLiTableInfo.php (modified) (1 diff)
- trunk/lib/vendor/creole/drivers/pgsql/PgSQLConnection.php (modified) (4 diffs)
- trunk/lib/vendor/creole/drivers/pgsql/PgSQLIdGenerator.php (modified) (1 diff)
- trunk/lib/vendor/creole/drivers/pgsql/PgSQLPreparedStatement.php (modified) (1 diff)
- trunk/lib/vendor/creole/drivers/pgsql/PgSQLResultSet.php (modified) (3 diffs)
- trunk/lib/vendor/creole/drivers/pgsql/PgSQLResultSetIterator.php (modified) (2 diffs)
- trunk/lib/vendor/creole/drivers/pgsql/metadata/PgSQLDatabaseInfo.php (modified) (3 diffs)
- trunk/lib/vendor/creole/drivers/sqlite/SQLiteResultSetIterator.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/vendor/creole/Creole.php
r497 r1404 178 178 179 179 // gather any flags from the DSN 180 if (!empty($dsninfo['persistent'])) $flags |= Creole::PERSISTENT; 181 if (!empty($dsninfo['compat_assoc_lower'])) $flags |= Creole::COMPAT_ASSOC_LOWER; 182 if (!empty($dsninfo['compat_rtrim_string'])) $flags |= Creole::COMPAT_RTRIM_STRING; 183 if (!empty($dsninfo['compat_all'])) $flags |= Creole::COMPAT_ALL; 180 if ( isset ( $dsninfo['persistent'] ) && ! empty ( $dsninfo['persistent'] ) ) 181 $flags |= Creole::PERSISTENT; 182 if ( isset ( $dsninfo['compat_assoc_lower'] ) && ! empty ( $dsninfo['compat_assoc_lower'] ) ) 183 $flags |= Creole::COMPAT_ASSOC_LOWER; 184 if ( isset ( $dsninfo['compat_rtrim_string'] ) && ! empty ( $dsninfo['compat_rtrim_string'] ) ) 185 $flags |= Creole::COMPAT_RTRIM_STRING; 186 if ( isset ( $dsninfo['compat_all'] ) && ! empty ( $dsninfo['compat_all'] ) ) 187 $flags |= Creole::COMPAT_ALL; 184 188 185 189 if ($flags & Creole::NO_ASSOC_LOWER) { trunk/lib/vendor/creole/common/PreparedStatementCommon.php
r497 r1404 318 318 } 319 319 320 if ($params) {321 for($i=0,$cnt=count($params); $i < $cnt; $i++) {322 $this->set($i+1, $params[$i]);323 }324 }320 foreach ( (array) $params as $i=>$param ) { 321 $this->set ( $i + 1, $param ); 322 unset ( $i, $param ); 323 } 324 unset ( $params ); 325 325 326 326 $this->updateCount = null; // reset … … 344 344 public function executeUpdate($params = null) 345 345 { 346 if ($params) {347 for($i=0,$cnt=count($params); $i < $cnt; $i++) { 348 $this->set($i+1, $params[$i]);349 }350 } 346 foreach ( (array) $params as $i=>$param ) { 347 $this->set ( $i + 1, $param ); 348 unset ( $i, $param ); 349 } 350 unset ( $params ); 351 351 352 352 if($this->resultSet) $this->resultSet->close(); … … 400 400 $type = 'float'; 401 401 break; 402 // nice at a later date for large int handling?403 //case 'gmp':404 402 } 405 $setter = 'set' . ucfirst($type); // PHP types are case-insensitive, but we'll do this in case that changes 406 $this->sql_cache_valid = false; 407 $this->$setter($paramIndex, $value); 408 } 403 $setter = 'set' . ucfirst($type); // PHP types are case-insensitive, but we'll do this in case that change 404 if ( method_exists ( $this, $setter ) ) { 405 $this->$setter($paramIndex, $value); 406 } else { 407 throw new SQLException ( "Unsupported datatype passed to set(): " . $type ); 408 } 409 } 409 410 } 410 411 trunk/lib/vendor/creole/drivers/mysqli/metadata/MySQLiTableInfo.php
r497 r1404 124 124 125 125 // Indexes 126 $res = mysqli_query($this->conn->getResource() ."SHOW INDEX FROM " . $this->name);126 $res = mysqli_query($this->conn->getResource(), "SHOW INDEX FROM " . $this->name); 127 127 128 128 // Loop through the returned results, grouping the same key_name together trunk/lib/vendor/creole/drivers/pgsql/PgSQLConnection.php
r497 r1404 142 142 throw new SQLException('Could not execute query', pg_last_error($this->dblink), $sql); 143 143 } 144 $this->result_affected_rows = @pg_affected_rows($result);144 $this->result_affected_rows = (int) @pg_affected_rows($result); 145 145 146 146 return new PgSQLResultSet($this, $result, $fetchmode); … … 168 168 protected function beginTrans() 169 169 { 170 $result = @pg_query($this->dblink, " begin");170 $result = @pg_query($this->dblink, "BEGIN"); 171 171 if (!$result) { 172 172 throw new SQLException('Could not begin transaction', pg_last_error($this->dblink)); … … 181 181 protected function commitTrans() 182 182 { 183 $result = @pg_query($this->dblink, " end");183 $result = @pg_query($this->dblink, "COMMIT"); 184 184 if (!$result) { 185 185 throw new SQLException('Could not commit transaction', pg_last_error($this->dblink)); … … 194 194 protected function rollbackTrans() 195 195 { 196 $result = @pg_query($this->dblink, " abort");196 $result = @pg_query($this->dblink, "ROLLBACK"); 197 197 if (!$result) { 198 198 throw new SQLException('Could not rollback transaction', pg_last_error($this->dblink)); trunk/lib/vendor/creole/drivers/pgsql/PgSQLIdGenerator.php
r497 r1404 76 76 throw new SQLException("You must specify the sequence name when calling getId() method."); 77 77 } 78 $rs = $this->conn->executeQuery(" select nextval('" . $name. "')", ResultSet::FETCHMODE_NUM);78 $rs = $this->conn->executeQuery("SELECT nextval('" . pg_escape_string ( $name ) . "')", ResultSet::FETCHMODE_NUM); 79 79 $rs->next(); 80 80 return $rs->getInt(1); trunk/lib/vendor/creole/drivers/pgsql/PgSQLPreparedStatement.php
r1 r1404 55 55 } else { 56 56 if (is_string($el)) { 57 $parts[] = '"' . pg_escape_string($el) . '"';57 $parts[] = '"' . $this->escape($el) . '"'; 58 58 } else { 59 59 $parts[] = $el; trunk/lib/vendor/creole/drivers/pgsql/PgSQLResultSet.php
r497 r1404 37 37 * @return PgSQLResultSetIterator 38 38 */ 39 /* 39 40 public function getIterator() 40 41 { … … 42 43 return new PgSQLResultSetIterator($this); 43 44 } 45 */ 44 46 45 47 /** … … 200 202 return ($this->fields[$column] === 't'); 201 203 } 202 204 203 205 } trunk/lib/vendor/creole/drivers/pgsql/PgSQLResultSetIterator.php
r1 r1404 29 29 * @package creole.drivers.pgsql 30 30 */ 31 class PgSQLResultSetIterator implements SeekableIterator {31 class PgSQLResultSetIterator implements SeekableIterator, Countable { 32 32 33 33 private $result; 34 34 private $pos = 0; 35 35 private $fetchmode; 36 private $row;37 36 private $row_count; 38 37 … … 94 93 function seek ( $index ) 95 94 { 95 if ( ! is_int ( $index ) ) { 96 throw new InvalidArgumentException ( 'Invalid arguement to seek' ); 97 } 96 98 if ( $index < 0 || $index > $this->row_count ) { 97 throw new Exception('Seeking to an unavailable index.');99 throw new OutOfBoundsException ( 'Invalid seek position' ); 98 100 } 99 101 $this->pos = $index; 100 102 } 103 104 function count ( ) { 105 return $this->row_count; 106 } 101 107 } trunk/lib/vendor/creole/drivers/pgsql/metadata/PgSQLDatabaseInfo.php
r497 r1404 40 40 41 41 // Get Database Version 42 $result = pg_exec ($this->conn->getResource(), "SELECT version() as ver"); 42 // TODO: www.php.net/pg_version 43 $result = pg_query ($this->conn->getResource(), "SELECT version() as ver"); 43 44 44 45 if (!$result) … … 55 56 $result = null; 56 57 57 $result = pg_ exec($this->conn->getResource(), "SELECT oid, relname FROM pg_class58 $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 58 59 WHERE relkind = 'r' AND relnamespace = (SELECT oid 59 60 FROM pg_namespace … … 87 88 $this->sequences = array(); 88 89 89 $result = pg_ exec($this->conn->getResource(), "SELECT oid, relname FROM pg_class90 $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 90 91 WHERE relkind = 'S' AND relnamespace = (SELECT oid 91 92 FROM pg_namespace trunk/lib/vendor/creole/drivers/sqlite/SQLiteResultSetIterator.php
r1 r1404 32 32 private $pos = 0; 33 33 private $fetchmode; 34 private $row;35 34 private $row_count; 36 35