cvs: pear /MDB2/MDB2/Driver/Reverse ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php

From: Date: Fri, 24 Feb 2006 11:09:11 +0000
Subject: cvs: pear /MDB2/MDB2/Driver/Reverse ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38560@lists.php.net to get a copy of this message
lsmith Fri Feb 24 11:09:11 2006 UTC Modified files: /pear/MDB2/MDB2/Driver/Reverse ibase.php mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php Log: - force assoc result rows to lower case keys (bug #6835)

http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/ibase.php?r1=1.39&r2=1.40&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/ibase.php diff -u pear/MDB2/MDB2/Driver/Reverse/ibase.php:1.39 pear/MDB2/MDB2/Driver/Reverse/ibase.php:1.40 --- pear/MDB2/MDB2/Driver/Reverse/ibase.php:1.39 Mon Feb 20 12:25:17 2006 +++ pear/MDB2/MDB2/Driver/Reverse/ibase.php Fri Feb 24 11:09:10 2006 @@ -42,7 +42,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.39 2006/02/20 12:25:17 quipo Exp $ +// $Id: ibase.php,v 1.40 2006/02/24 11:09:10 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -161,14 +161,13 @@ return $db->raiseError(MDB2_ERROR, null, null, 'getTableFieldDefinition: it was not specified an existing table column'); } + $column = array_change_key_case($column, CASE_LOWER); if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { $column['name'] = strtolower($column['name']); } else { $column['name'] = strtoupper($column['name']); } - } else { - $column = array_change_key_case($column, $db->options['field_case']); } $column['type'] = array_key_exists($column['field_type_code'], $this->types) @@ -244,8 +243,10 @@ return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'getTableIndexDefinition: it was not specified an existing table index'); } + $fields = array(); do { + $row = array_change_key_case($row, CASE_LOWER); $fields[] = $row['field_name']; } while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))); $result->free(); @@ -310,6 +311,7 @@ } $fields = array(); do { + $row = array_change_key_case($row, CASE_LOWER); $fields[] = $row['field_name']; } while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))); $result->free(); http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/mssql.php?r1=1.19&r2=1.20&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/mssql.php diff -u pear/MDB2/MDB2/Driver/Reverse/mssql.php:1.19 pear/MDB2/MDB2/Driver/Reverse/mssql.php:1.20 --- pear/MDB2/MDB2/Driver/Reverse/mssql.php:1.19 Sat Dec 10 17:06:34 2005 +++ pear/MDB2/MDB2/Driver/Reverse/mssql.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.19 2005/12/10 17:06:34 lsmith Exp $ +// $Id: mssql.php,v 1.20 2006/02/24 11:09:11 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -202,6 +202,7 @@ $res = $db->queryAll("EXEC SP_HELPINDEX[$table]", null, MDB2_FETCHMODE_ASSOC); foreach ($res as $val) { + $val = array_change_key_case($val, CASE_LOWER); $keys = explode(', ', $val['index_keys']); if (sizeof($keys) > 1) { @@ -225,7 +226,7 @@ $res = $db->queryAll("EXEC SP_COLUMNS[$table]", null, MDB2_FETCHMODE_ASSOC); foreach ($res as $val) { - $val = array_change_key_case($val, $db->options['field_case']); + $val = array_change_key_case($val, CASE_LOWER); if ($val['nullable'] == '0') { $this->_add_flag($flags[$val['column_name']], 'not_null'); } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/mysql.php?r1=1.42&r2=1.43&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/mysql.php diff -u pear/MDB2/MDB2/Driver/Reverse/mysql.php:1.42 pear/MDB2/MDB2/Driver/Reverse/mysql.php:1.43 --- pear/MDB2/MDB2/Driver/Reverse/mysql.php:1.42 Mon Feb 13 07:34:11 2006 +++ pear/MDB2/MDB2/Driver/Reverse/mysql.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.42 2006/02/13 07:34:11 lsmith Exp $ +// $Id: mysql.php,v 1.43 2006/02/24 11:09:11 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -82,6 +82,7 @@ return $columns; } foreach ($columns as $column) { + $column = array_change_key_case($column, CASE_LOWER); $column['name'] = $column['field']; unset($column['field']); if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { @@ -162,11 +163,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['key_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { @@ -230,11 +227,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['key_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/mysqli.php?r1=1.29&r2=1.30&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/mysqli.php diff -u pear/MDB2/MDB2/Driver/Reverse/mysqli.php:1.29 pear/MDB2/MDB2/Driver/Reverse/mysqli.php:1.30 --- pear/MDB2/MDB2/Driver/Reverse/mysqli.php:1.29 Mon Feb 13 07:34:11 2006 +++ pear/MDB2/MDB2/Driver/Reverse/mysqli.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.29 2006/02/13 07:34:11 lsmith Exp $ +// $Id: mysqli.php,v 1.30 2006/02/24 11:09:11 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -136,6 +136,7 @@ return $columns; } foreach ($columns as $column) { + $column = array_change_key_case($column, CASE_LOWER); $column['name'] = $column['field']; unset($column['field']); if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { @@ -213,11 +214,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['key_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { @@ -281,11 +278,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['key_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/oci8.php?r1=1.19&r2=1.20&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/oci8.php diff -u pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.19 pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.20 --- pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.19 Wed Feb 15 21:28:01 2006 +++ pear/MDB2/MDB2/Driver/Reverse/oci8.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: oci8.php,v 1.19 2006/02/15 21:28:01 lsmith Exp $ +// $Id: oci8.php,v 1.20 2006/02/24 11:09:11 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -88,52 +88,52 @@ if (PEAR::isError($column)) { return $column; } - if ($column) { - if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_case'] == CASE_LOWER) { - $column['name'] = strtolower($column['name']); - } else { - $column['name'] = strtoupper($column['name']); - } + + if (empty($column)) { + return $db->raiseError(MDB2_ERROR, null, null, + 'getTableFieldDefinition: it was not specified an existing table column'); + } + + $column = array_change_key_case($column, CASE_LOWER); + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + if ($db->options['field_case'] == CASE_LOWER) { + $column['name'] = strtolower($column['name']); } else { - $column = array_change_key_case($column, $db->options['field_case']); + $column['name'] = strtoupper($column['name']); } - list($types, $length, $unsigned) = $db->datatype->mapNativeDatatype($column); - $notnull = false; - if (array_key_exists('nullable', $column) && $column['nullable'] == 'N') { - $notnull = true; - } - $default = false; - if (array_key_exists('default', $column)) { - $default = $column['default']; - if ($default === 'NULL') { - $default = null; - } - if (is_null($default) && $notnull) { - $default = ''; - } + } + list($types, $length, $unsigned) = $db->datatype->mapNativeDatatype($column); + $notnull = false; + if (array_key_exists('nullable', $column) && $column['nullable'] == 'N') { + $notnull = true; + } + $default = false; + if (array_key_exists('default', $column)) { + $default = $column['default']; + if ($default === 'NULL') { + $default = null; } - $definition = array(); - foreach ($types as $key => $type) { - $definition[$key] = array( - 'type' => $type, - 'notnull' => $notnull, - ); - if ($length > 0) { - $definition[$key]['length'] = $length; - } - if ($unsigned) { - $definition[$key]['unsigned'] = true; - } - if ($default !== false) { - $definition[$key]['default'] = $default; - } + if (is_null($default) && $notnull) { + $default = ''; } - return $definition; } - - return $db->raiseError(MDB2_ERROR, null, null, - 'getTableFieldDefinition: it was not specified an existing table column'); + $definition = array(); + foreach ($types as $key => $type) { + $definition[$key] = array( + 'type' => $type, + 'notnull' => $notnull, + ); + if ($length > 0) { + $definition[$key]['length'] = $length; + } + if ($unsigned) { + $definition[$key]['unsigned'] = true; + } + if ($default !== false) { + $definition[$key]['default'] = $default; + } + } + return $definition; } // }}} @@ -163,12 +163,8 @@ return $row; } $definition = array(); - if ($row) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + if (!empty($row)) { + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['index_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { @@ -183,6 +179,7 @@ return $result; } while ($colrow = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) { + $colrow = array_change_key_case($colrow, CASE_LOWER); $column_name = $colrow['column_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { @@ -238,11 +235,7 @@ } $definition = array(); while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) { - if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) - || $db->options['field_case'] != CASE_LOWER - ) { - $row = array_change_key_case($row, CASE_LOWER); - } + $row = array_change_key_case($row, CASE_LOWER); $key_name = $row['constraint_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { @@ -259,6 +252,7 @@ $query.= $db->quote($key_name, 'text').' AND table_name = '.$table; $colres = $db->query($query); while ($colrow = $colres->fetchRow(MDB2_FETCHMODE_ASSOC)) { + $colrow = array_change_key_case($colrow, CASE_LOWER); $column_name = $row['column_name']; if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/pgsql.php?r1=1.37&r2=1.38&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/pgsql.php diff -u pear/MDB2/MDB2/Driver/Reverse/pgsql.php:1.37 pear/MDB2/MDB2/Driver/Reverse/pgsql.php:1.38 --- pear/MDB2/MDB2/Driver/Reverse/pgsql.php:1.37 Mon Feb 13 07:34:11 2006 +++ pear/MDB2/MDB2/Driver/Reverse/pgsql.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.37 2006/02/13 07:34:11 lsmith Exp $ +// $Id: pgsql.php,v 1.38 2006/02/24 11:09:11 lsmith Exp $ require_once 'MDB2/Driver/Reverse/Common.php'; @@ -94,6 +94,7 @@ if (PEAR::isError($column)) { return $column; } + $column = array_change_key_case($column, CASE_LOWER); list($types, $length, $unsigned) = $db->datatype->mapNativeDatatype($column); $notnull = false; if (array_key_exists('attnotnull', $column) && $column['attnotnull'] == 't') { @@ -156,11 +157,15 @@ $row = $db->queryRow($query, null, MDB2_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; - } elseif (!$row) { + } + + if (empty($row)) { return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'getTableIndexDefinition: it was not specified an existing table index'); } + $row = array_change_key_case($row, CASE_LOWER); + $db->loadModule('Manager', null, true); $columns = $db->manager->listTableFields($table); @@ -198,11 +203,15 @@ $row = $db->queryRow($query, null, MDB2_FETCHMODE_ASSOC); if (PEAR::isError($row)) { return $row; - } elseif (!$row) { + } + + if (empty($row)) { return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'getTableConstraintDefinition: it was not specified an existing table constraint'); } + $row = array_change_key_case($row, CASE_LOWER); + $db->loadModule('Manager', null, true); $columns = $db->manager->listTableFields($table); http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Reverse/sqlite.php?r1=1.40&r2=1.41&diff_format=u Index: pear/MDB2/MDB2/Driver/Reverse/sqlite.php diff -u pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.40 pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.41 --- pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.40 Mon Feb 13 07:34:11 2006 +++ pear/MDB2/MDB2/Driver/Reverse/sqlite.php Fri Feb 24 11:09:11 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.40 2006/02/13 07:34:11 lsmith Exp $ +// $Id: sqlite.php,v 1.41 2006/02/24 11:09:11 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -349,19 +349,18 @@ return $db; } - if (is_string($result)) { - /* - * Probably received a table name. - * Create a result resource identifier. - */ - $id = $db->queryAll("PRAGMA table_info('$result');", null, MDB2_FETCHMODE_ASSOC); - $got_string = true; - } else { + if (!is_string($result)) { return $db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null, - 'This DBMS can not obtain tableInfo' . - ' from result sets'); + 'This DBMS can not obtain tableInfo from result sets'); } + /* + * Probably received a table name. + * Create a result resource identifier. + */ + $id = $db->queryAll("PRAGMA table_info('$result');", null, MDB2_FETCHMODE_ASSOC); + $got_string = true; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { if ($db->options['field_case'] == CASE_LOWER) { $case_func = 'strtolower'; @@ -381,6 +380,7 @@ $db->loadModule('Datatype', null, true); for ($i = 0; $i < $count; $i++) { + $id[$i] = array_change_key_case($id[$i], CASE_LOWER); if (strpos($id[$i]['type'], '(') !== false) { $bits = explode('(', $id[$i]['type']); $type = $bits[0];
« previous php.pear.cvs (#38560) next »