cvs: pear /MDB2/MDB2/Driver/Datatype Common.php
| From: | Lukas Smith | Date: | Fri, 22 Oct 2004 20:38:13 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver/Datatype Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-25079@lists.php.net to get a copy of this message | ||
lsmith Fri Oct 22 16:38:13 2004 EDT
Modified files:
/pear/MDB2/MDB2/Driver/Datatype Common.php
Log:
- removed serialize code
- refactored LOB handling
http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/Datatype/Common.php?r1=1.14&r2=1.15&ty=u
Index: pear/MDB2/MDB2/Driver/Datatype/Common.php
diff -u pear/MDB2/MDB2/Driver/Datatype/Common.php:1.14
pear/MDB2/MDB2/Driver/Datatype/Common.php:1.15
--- pear/MDB2/MDB2/Driver/Datatype/Common.php:1.14 Thu Sep 9 15:13:37 2004
+++ pear/MDB2/MDB2/Driver/Datatype/Common.php Fri Oct 22 16:38:12 2004
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.14 2004/09/09 19:13:37 lsmith Exp $
+// $Id: Common.php,v 1.15 2004/10/22 20:38:12 lsmith Exp $
/**
* @package MDB2
@@ -61,7 +61,6 @@
{
var $valid_types = array(
'text' => true,
-# 'serialize' => true,
'boolean' => true,
'integer' => true,
'decimal' => true,
@@ -96,8 +95,8 @@
* Define the list of types to be associated with the columns of a given
* result set.
*
- * This function may be called before invoking fetch(),
- * fetchRow(), fetchCol() and fetchAll() so that the necessary data type
+ * This function may be called before invoking fetchRow(), fetchOne()
+ * fetchCole() and fetchAll() so that the necessary data type
* conversions are performed on the data to be retrieved by them. If this
* function is not called, the type of all result set columns is assumed
* to be text, thus leading to not perform any conversions.
@@ -146,8 +145,6 @@
switch ($type) {
case 'text':
return $value;
-# case 'serialize':
-# return $value ? @unserialize($value) : $value;
case 'integer':
return intval($value);
case 'boolean':
@@ -342,38 +339,6 @@
}
// }}}
- // {{{ _getSerializeDeclaration()
-
- /**
- * Obtain DBMS specific SQL code portion needed to declare an text type
- * field to be used in statements like CREATE TABLE.
- *
- * @param string $name name the field to be declared.
- * @param string $field associative array with the name of the properties
- * of the field being declared as array indexes. Currently, the types
- * of supported field properties are as follows:
- *
- * length
- * Integer value that determines the maximum length of the text
- * field. If this argument is missing the field should be
- * declared to have the longest length allowed by the DBMS.
- *
- * default
- * Text value to be used as default for this field.
- *
- * notnull
- * Boolean flag that indicates whether this field is constrained
- * to not be set to null.
- * @return string DBMS specific SQL code portion that should be used to
- * declare the specified field.
- * @access private
- */
-# function _getSerializeDeclaration($name, $field)
-# {
-# return $this->_getTextDeclaration($name, $field);
-# }
-
- // }}}
// {{{ _getCLOBDeclaration()
/**
@@ -658,7 +623,6 @@
break;
case 'array':
case 'object':
-# $type = 'serialize';
$type = 'text';
break;
default:
@@ -716,21 +680,59 @@
return "'".$db->escape($value)."'";
}
- // {{{ _quoteSerialize()
+ // }}}
+ // {{{ _readFile()
/**
- * Convert a serialize value into a DBMS specific format that is suitable to
+ * Convert a text value into a DBMS specific format that is suitable to
* compose query statements.
*
- * @param string $value text string value that is intended to be converted.
- * @return string text string that already contains any DBMS specific
- * escaped character sequences.
+ * @param $value
+ * @return string text string that represents the given argument value in
+ * a DBMS specific format.
+ * @access private
+ */
+ function _readFile($value)
+ {
+ $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
+ $close = false;
+ if (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) {
+ $close = true;
+ if ($match[1] == 'file://') {
+ $value = $match[2];
+ }
+ $value = @fopen($value, 'r');
+ }
+ if (is_resource($value)) {
+ $fp = $value;
+ $value = '';
+ while (!@feof($fp)) {
+ $value .= @fread($fp, $db->options['lob_buffer_length']);
+ }
+ if ($close) {
+ @fclose($fp);
+ }
+ }
+ return $value;
+ }
+
+ // }}}
+ // {{{ _quoteLOB()
+
+ /**
+ * Convert a text value into a DBMS specific format that is suitable to
+ * compose query statements.
+ *
+ * @param $value
+ * @return string text string that represents the given argument value in
+ * a DBMS specific format.
* @access private
*/
-# function _quoteSerialize($value)
-# {
-# return $this->quote(serialize($value), 'text');
-# }
+ function _quoteLOB($value)
+ {
+ $value = $this->_readFile($value);
+ return $this->_quoteText($value);
+ }
// }}}
// {{{ _quoteCLOB()
@@ -739,8 +741,6 @@
* Convert a text value into a DBMS specific format that is suitable to
* compose query statements.
*
- * @param resource $prepared_query query handle from prepare()
- * @param $parameter
* @param $value
* @return string text string that represents the given argument value in
* a DBMS specific format.
@@ -748,7 +748,7 @@
*/
function _quoteCLOB($value)
{
- return $this->_quoteText($value);
+ return $this->_quoteLOB($value);
}
// }}}
@@ -773,8 +773,6 @@
* Convert a text value into a DBMS specific format that is suitable to
* compose query statements.
*
- * @param resource $prepared_query query handle from prepare()
- * @param $parameter
* @param $value
* @return string text string that represents the given argument value in
* a DBMS specific format.
@@ -782,7 +780,7 @@
*/
function _quoteBLOB($value)
{
- return $this->_quoteText($value);
+ return $this->_quoteLOB($value);
}
// }}}