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

From: Date: Fri, 14 Apr 2006 11:05:57 +0000
Subject: cvs: pear /MDB2/MDB2/Driver/Datatype 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-39612@lists.php.net to get a copy of this message
lsmith Fri Apr 14 11:05:57 2006 UTC Modified files: /pear/MDB2/MDB2/Driver/Datatype mssql.php mysql.php mysqli.php oci8.php pgsql.php sqlite.php Log: - added support for length in reverse engineering - some fixes regarding boolean reverse engineering

http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/mssql.php?r1=1.28&r2=1.29&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mssql.php diff -u pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.28 pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.29 --- pear/MDB2/MDB2/Driver/Datatype/mssql.php:1.28 Tue Mar 14 22:38:30 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mssql.php Fri Apr 14 11:05:57 2006 @@ -44,7 +44,7 @@ // | Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.28 2006/03/14 22:38:30 davidc Exp $ +// $Id: mssql.php,v 1.29 2006/04/14 11:05:57 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -217,6 +217,7 @@ { $db_type = preg_replace('/\d/','', strtolower($field['type']) ); $length = $field['length']; + // todo: is this not just copied from pgsql? if ($length == '-1' && array_key_exists('atttypmod', $field)) { $length = $field['atttypmod'] - 4; } @@ -224,31 +225,38 @@ $length = null; } $type = array(); + // todo: unsigned handling seems to be missing $unsigned = null; switch ($db_type) { - case 'bit': - $type[0] = 'boolean'; - break; - case 'int': - $type[0] = 'integer'; - break; - case 'datetime': - $type[0] = 'timestamp'; - break; - case 'float': - case 'real': - case 'numeric': + case 'bit': + $type[0] = 'boolean'; + break; + case 'int': + $type[0] = 'integer'; + break; + case 'datetime': + $type[0] = 'timestamp'; + break; + case 'float': + case 'real': + case 'numeric': $type[0] = 'float'; - break; + break; case 'decimal': - case 'money': + case 'money': $type[0] = 'decimal'; - break; - case 'text': - case 'char': - case 'varchar': - $type[0] = 'text'; - break; + break; + case 'text': + case 'char': + case 'varchar': + $type[0] = 'text'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + } + break; default: $db =& $this->getDBInstance(); if (PEAR::isError($db)) { http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/mysql.php?r1=1.34&r2=1.35&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mysql.php diff -u pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.34 pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.35 --- pear/MDB2/MDB2/Driver/Datatype/mysql.php:1.34 Wed Mar 1 12:15:33 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mysql.php Fri Apr 14 11:05:57 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.34 2006/03/01 12:15:33 lsmith Exp $ +// $Id: mysql.php,v 1.35 2006/04/14 11:05:57 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -257,19 +257,34 @@ $unsigned = null; switch ($db_type) { case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 1; + break; case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 2; + break; case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 3; + break; case 'int': case 'integer': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 4; + break; case 'bigint': $type[] = 'integer'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); - } - } $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 8; break; case 'char': case 'varchar': http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/mysqli.php?r1=1.30&r2=1.31&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/mysqli.php diff -u pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.30 pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.31 --- pear/MDB2/MDB2/Driver/Datatype/mysqli.php:1.30 Wed Mar 1 12:15:33 2006 +++ pear/MDB2/MDB2/Driver/Datatype/mysqli.php Fri Apr 14 11:05:57 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: mysqli.php,v 1.30 2006/03/01 12:15:33 lsmith Exp $ +// $Id: mysqli.php,v 1.31 2006/04/14 11:05:57 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -257,19 +257,34 @@ $unsigned = null; switch ($db_type) { case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 1; + break; case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 2; + break; case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 3; + break; case 'int': case 'integer': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 4; + break; case 'bigint': $type[] = 'integer'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); - } - } $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 8; break; case 'char': case 'varchar': http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/oci8.php?r1=1.43&r2=1.44&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/oci8.php diff -u pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.43 pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.44 --- pear/MDB2/MDB2/Driver/Datatype/oci8.php:1.43 Tue Mar 21 11:15:07 2006 +++ pear/MDB2/MDB2/Driver/Datatype/oci8.php Fri Apr 14 11:05:57 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ -// $Id: oci8.php,v 1.43 2006/03/21 11:15:07 lsmith Exp $ +// $Id: oci8.php,v 1.44 2006/04/14 11:05:57 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -314,6 +314,12 @@ case 'char': case 'nchar': $type[] = 'text'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + } break; case 'date': case 'timestamp': @@ -326,6 +332,12 @@ case 'number': if (strpos($length, ',') === false) { $type[] = 'integer'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + } } else { $type[] = 'decimal'; } http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/pgsql.php?r1=1.47&r2=1.48&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/pgsql.php diff -u pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.47 pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.48 --- pear/MDB2/MDB2/Driver/Datatype/pgsql.php:1.47 Wed Mar 1 12:15:33 2006 +++ pear/MDB2/MDB2/Driver/Datatype/pgsql.php Fri Apr 14 11:05:57 2006 @@ -42,7 +42,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.47 2006/03/01 12:15:33 lsmith Exp $ +// $Id: pgsql.php,v 1.48 2006/04/14 11:05:57 lsmith Exp $ require_once 'MDB2/Driver/Datatype/Common.php'; @@ -520,19 +520,30 @@ $unsigned = null; switch ($db_type) { case 'smallint': + case 'int2': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 2; + break; case 'int': + case 'int4': case 'integer': - case 'bigint': case 'serial': + case 'serial4': $type[] = 'integer'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); - } - } + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 4; + break; + case 'bigint': + case 'int8': + case 'bigserial': + case 'serial8': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 8; break; case 'bool': + case 'boolean': $type[] = 'boolean'; $length = null; break; @@ -542,12 +553,7 @@ case 'varchar': case 'bpchar': $type[] = 'text'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); - } - } elseif (strstr($db_type, 'text')) { + if (strstr($db_type, 'text')) { $type[] = 'clob'; } break; http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Datatype/sqlite.php?r1=1.42&r2=1.43&diff_format=u Index: pear/MDB2/MDB2/Driver/Datatype/sqlite.php diff -u pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.42 pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.43 --- pear/MDB2/MDB2/Driver/Datatype/sqlite.php:1.42 Wed Mar 1 12:15:33 2006 +++ pear/MDB2/MDB2/Driver/Datatype/sqlite.php Fri Apr 14 11:05:57 2006 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.42 2006/03/01 12:15:33 lsmith Exp $ +// $Id: sqlite.php,v 1.43 2006/04/14 11:05:57 lsmith Exp $ // require_once 'MDB2/Driver/Datatype/Common.php'; @@ -225,19 +225,36 @@ $type[] = 'boolean'; break; case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 1; + break; case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 2; + break; case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 3; + break; case 'int': case 'integer': + case 'serial': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 4; + break; case 'bigint': + case 'bigserial': $type[] = 'integer'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); - } - } - $type[] = 'decimal'; + $unsigned = preg_match('/ unsigned/i', $db_type); + $length = 8; break; case 'clob': case 'tinytext':
« previous php.pear.cvs (#39612) next »