cvs: pear /MDB2/MDB2/Driver/Reverse sqlite.php

From: Date: Fri, 14 Oct 2005 09:43:11 +0000
Subject: cvs: pear /MDB2/MDB2/Driver/Reverse sqlite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35513@lists.php.net to get a copy of this message
lsmith Fri Oct 14 05:43:11 2005 EDT Modified files: /pear/MDB2/MDB2/Driver/Reverse sqlite.php Log: - fixed getTableFieldDefinition() http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Reverse/sqlite.php?r1=1.24&r2=1.25&ty=u Index: pear/MDB2/MDB2/Driver/Reverse/sqlite.php diff -u pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.24 pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.25 --- pear/MDB2/MDB2/Driver/Reverse/sqlite.php:1.24 Fri Oct 7 07:55:20 2005 +++ pear/MDB2/MDB2/Driver/Reverse/sqlite.php Fri Oct 14 05:43:10 2005 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.24 2005/10/07 11:55:20 lsmith Exp $ +// $Id: sqlite.php,v 1.25 2005/10/14 09:43:10 lsmith Exp $ // require_once 'MDB2/Driver/Reverse/Common.php'; @@ -56,11 +56,11 @@ */ class MDB2_Driver_Reverse_sqlite extends MDB2_Driver_Reverse_Common { - function _getTableColumns($query) + function _getTableColumns($sql) { - $start_pos = strpos($query, '('); - $end_pos = strrpos($query, ')'); - $column_def = substr($query, $start_pos+1, $end_pos-$start_pos-1); + $start_pos = strpos($sql, '('); + $end_pos = strrpos($sql, ')'); + $column_def = substr($sql, $start_pos+1, $end_pos-$start_pos-1); $column_sql = split(',', $column_def); $columns = array(); $count = count($column_sql); @@ -85,6 +85,9 @@ if (strlen($default) && $default[0]=="'") { $default = str_replace("''", "'", substr($default, 1, strlen($default)-2)); } + if ($default === 'NULL') { + $default = null; + } $columns[$j]['default'] = $default; } if (isset($matches[10]) && strlen($matches[10])) { @@ -121,11 +124,10 @@ if (PEAR::isError($sql)) { return $sql; } - // todo: broken!!! - $columns = explode(', ', $sql); + $columns = $this->_getTableColumns($sql); foreach ($columns as $column) { if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { - if ($db->options['field_change'] == CASE_LOWER) { + if ($db->options['field_case'] == CASE_LOWER) { $column['name'] = strtolower($column['name']); } else { $column['name'] = strtoupper($column['name']); @@ -136,8 +138,8 @@ if ($field_name == $column['name']) { list($types, $length) = $db->datatype->mapNativeDatatype($column); $notnull = false; - if (array_key_exists('null', $column) && $column['null'] != 'YES') { - $notnull = true; + if (array_key_exists('notnull', $column)) { + $notnull = $column['notnull']; } $default = false; if (array_key_exists('default', $column)) {

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