summaryrefslogtreecommitdiff
path: root/extlib/DB/DataObject
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-07-15 23:35:20 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-07-15 23:35:20 -0400
commit77faf7610b430e2489170f7a43ac98d76ed8f5a6 (patch)
tree9a95d0f45171d368240a8b9ba0cc813c48eded9e /extlib/DB/DataObject
parenteb22f06ac6ca30b850be71cbb8358c0715eca7f9 (diff)
upgrade to latest version of DB_DataObject
Diffstat (limited to 'extlib/DB/DataObject')
-rw-r--r--extlib/DB/DataObject/Cast.php9
-rw-r--r--extlib/DB/DataObject/Error.php2
-rw-r--r--extlib/DB/DataObject/Generator.php68
-rw-r--r--[-rwxr-xr-x]extlib/DB/DataObject/createTables.php2
4 files changed, 51 insertions, 30 deletions
diff --git a/extlib/DB/DataObject/Cast.php b/extlib/DB/DataObject/Cast.php
index 616abb55e..095d2a4d2 100644
--- a/extlib/DB/DataObject/Cast.php
+++ b/extlib/DB/DataObject/Cast.php
@@ -15,9 +15,9 @@
* @category Database
* @package DB_DataObject
* @author Alan Knowles <alan@akbkhome.com>
- * @copyright 1997-2006 The PHP Group
+ * @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Cast.php,v 1.15 2005/07/07 05:30:53 alan_k Exp $
+ * @version CVS: $Id: Cast.php 264148 2008-08-04 03:44:59Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
@@ -391,7 +391,10 @@ class DB_DataObject_Cast {
// this is funny - the parameter order is reversed ;)
return "'".mysqli_real_escape_string($db->connection, $this->value)."'";
-
+ case 'sqlite':
+ // this is funny - the parameter order is reversed ;)
+ return "'".sqlite_escape_string($this->value)."'";
+
default:
return PEAR::raiseError("DB_DataObject_Cast cant handle blobs for Database:{$db->dsn['phptype']} Yet");
diff --git a/extlib/DB/DataObject/Error.php b/extlib/DB/DataObject/Error.php
index 05a741408..382115453 100644
--- a/extlib/DB/DataObject/Error.php
+++ b/extlib/DB/DataObject/Error.php
@@ -18,7 +18,7 @@
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Error.php,v 1.3 2005/03/23 02:35:35 alan_k Exp $
+ * @version CVS: $Id: Error.php 277015 2009-03-12 05:51:03Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
diff --git a/extlib/DB/DataObject/Generator.php b/extlib/DB/DataObject/Generator.php
index de16af692..ff6e42c7d 100644
--- a/extlib/DB/DataObject/Generator.php
+++ b/extlib/DB/DataObject/Generator.php
@@ -4,9 +4,9 @@
*
* PHP versions 4 and 5
*
- * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
@@ -14,8 +14,8 @@
* @package DB_DataObject
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Generator.php,v 1.141 2008/01/30 02:29:39 alan_k Exp $
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
+ * @version CVS: $Id: Generator.php 284150 2009-07-15 23:27:59Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
@@ -193,7 +193,11 @@ class DB_DataObject_Generator extends DB_DataObject
/**
* set portability and some modules to fetch the informations
*/
- $__DB->setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_FIX_CASE);
+ $db_options = PEAR::getStaticProperty('MDB2','options');
+ if (empty($db_options)) {
+ $__DB->setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_FIX_CASE);
+ }
+
$__DB->loadModule('Manager');
$__DB->loadModule('Reverse');
}
@@ -265,12 +269,7 @@ class DB_DataObject_Generator extends DB_DataObject
} else {
$defs = $__DB->reverse->tableInfo($quotedTable);
// rename the length value, so it matches db's return.
- foreach ($defs as $k => $v) {
- if (!isset($defs[$k]['length'])) {
- continue;
- }
- $defs[$k]['len'] = $defs[$k]['length'];
- }
+
}
if (is_a($defs,'PEAR_Error')) {
@@ -286,7 +285,10 @@ class DB_DataObject_Generator extends DB_DataObject
if (!is_array($def)) {
continue;
}
-
+ // rename the length value, so it matches db's return.
+ if (isset($def['length']) && !isset($def['len'])) {
+ $def['len'] = $def['length'];
+ }
$this->_definitions[$table][] = (object) $def;
}
@@ -391,7 +393,10 @@ class DB_DataObject_Generator extends DB_DataObject
$fk = array();
foreach($this->tables as $this->table) {
- $res =& $DB->query('SHOW CREATE TABLE ' . $this->table);
+ $quotedTable = !empty($options['quote_identifiers_tableinfo']) ? $DB->quoteIdentifier($table) : $this->table;
+
+ $res =& $DB->query('SHOW CREATE TABLE ' . $quotedTable );
+
if (PEAR::isError($res)) {
die($res->getMessage());
}
@@ -467,7 +472,7 @@ class DB_DataObject_Generator extends DB_DataObject
function _generateDefinitionsTable()
{
global $_DB_DATAOBJECT;
-
+ $options = PEAR::getStaticProperty('DB_DataObject','options');
$defs = $this->_definitions[$this->table];
$this->_newConfig .= "\n[{$this->table}]\n";
$keys_out = "\n[{$this->table}__keys]\n";
@@ -551,6 +556,9 @@ class DB_DataObject_Generator extends DB_DataObject
case 'ENUM':
case 'SET': // not really but oh well
+
+ case 'POINT': // mysql geometry stuff - not really string - but will do..
+
case 'TIMESTAMPTZ': // postgres
case 'BPCHAR': // postgres
case 'INTERVAL': // postgres (eg. '12 days')
@@ -594,14 +602,18 @@ class DB_DataObject_Generator extends DB_DataObject
DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME;
break;
-
- case 'TINYBLOB':
+
case 'BLOB': /// these should really be ignored!!!???
+ case 'TINYBLOB':
case 'MEDIUMBLOB':
case 'LONGBLOB':
+
+ case 'CLOB': // oracle character lob support
+
case 'BYTEA': // postgres blob support..
$type = DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB;
break;
+
default:
echo "*****************************************************************\n".
"** WARNING UNKNOWN TYPE **\n".
@@ -653,7 +665,9 @@ class DB_DataObject_Generator extends DB_DataObject
// only use primary key or nextval(), cause the setFrom blocks you setting all key items...
// if no keys exist fall back to using unique
//echo "\n{$t->name} => {$t->flags}\n";
- if (preg_match("/(auto_increment|nextval\()/i",rawurldecode($t->flags))
+ $secondary_key_match = isset($options['generator_secondary_key_match']) ? $options['generator_secondary_key_match'] : 'primary|unique';
+
+ if (preg_match('/(auto_increment|nextval\()/i',rawurldecode($t->flags))
|| (isset($t->autoincrement) && ($t->autoincrement === true))) {
// native sequences = 2
@@ -662,7 +676,7 @@ class DB_DataObject_Generator extends DB_DataObject
}
$ret_keys_primary[$t->name] = 'N';
- } else if (preg_match("/(primary|unique)/i",$t->flags)) {
+ } else if ($secondary_key_match && preg_match('/('.$secondary_key_match.')/i',$t->flags)) {
// keys.. = 1
$key_type = 'K';
if (!preg_match("/(primary)/i",$t->flags)) {
@@ -868,10 +882,13 @@ class DB_DataObject_Generator extends DB_DataObject
// then we should add var $_database = here
// as database names may not always match..
+ if (empty($GLOBALS['_DB_DATAOBJECT']['CONFIG'])) {
+ DB_DataObject::_loadConfig();
+ }
+
+ // Only include the $_database property if the omit_database_var is unset or false
-
-
- if (isset($options["database_{$this->_database}"])) {
+ if (isset($options["database_{$this->_database}"]) && empty($GLOBALS['_DB_DATAOBJECT']['CONFIG']['generator_omit_database_var'])) {
$body .= " {$var} \$_database = '{$this->_database}'; {$p}// database name (used with database_{*} config)\n";
}
@@ -904,9 +921,10 @@ class DB_DataObject_Generator extends DB_DataObject
$padding = (30 - strlen($t->name));
if ($padding < 2) $padding =2;
$p = str_repeat(' ',$padding) ;
-
- $body .=" {$var} \${$t->name}; {$p}// {$t->type}({$t->len}) {$t->flags}\n";
-
+
+ $length = empty($t->len) ? '' : '('.$t->len.')';
+ $body .=" {$var} \${$t->name}; {$p}// {$t->type}$length {$t->flags}\n";
+
// can not do set as PEAR::DB table info doesnt support it.
//if (substr($t->Type,0,3) == "set")
// $sets[$t->Field] = "array".substr($t->Type,3);
@@ -1185,7 +1203,7 @@ class DB_DataObject_Generator extends DB_DataObject
$__DB->loadModule('Manager');
$__DB->loadModule('Reverse');
}
- $quotedTable = !empty($options['quote_identifiers']) ?
+ $quotedTable = !empty($options['quote_identifiers_tableinfo']) ?
$__DB->quoteIdentifier($table) : $table;
if (!$is_MDB2) {
diff --git a/extlib/DB/DataObject/createTables.php b/extlib/DB/DataObject/createTables.php
index c0659574e..d54d28c24 100755..100644
--- a/extlib/DB/DataObject/createTables.php
+++ b/extlib/DB/DataObject/createTables.php
@@ -16,7 +16,7 @@
// | Author: Alan Knowles <alan@akbkhome.com>
// +----------------------------------------------------------------------+
//
-// $Id: createTables.php,v 1.24 2006/01/13 01:27:55 alan_k Exp $
+// $Id: createTables.php 277015 2009-03-12 05:51:03Z alan_k $
//
// since this version doesnt use overload,