alecpl
2010-01-26 2273d4117fd50ee44dcdaa28fd6444383dc403a0
program/lib/MDB2/Driver/Datatype/Common.php
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org>                           |
// +----------------------------------------------------------------------+
//
// $Id: Common.php,v 1.137 2008/02/17 18:53:40 afz Exp $
// $Id: Common.php 292715 2009-12-28 14:06:34Z quipo $
require_once 'MDB2/LOB.php';
@@ -232,7 +232,7 @@
     */
    function convertResult($value, $type, $rtrim = true)
    {
        if (is_null($value)) {
        if (null === $value) {
            return null;
        }
        $db =& $this->getDBInstance();
@@ -313,7 +313,7 @@
        if (count($types)) {
            reset($types);
            foreach (array_keys($sorted_types) as $k) {
                if (is_null($sorted_types[$k])) {
                if (null === $sorted_types[$k]) {
                    $sorted_types[$k] = current($types);
                    next($types);
                }
@@ -511,7 +511,7 @@
                    $field['default'] = ' ';
                }
            }
            if (!is_null($field['default'])) {
            if (null !== $field['default']) {
                $default = ' DEFAULT ' . $this->quote($field['default'], $field['type']);
            }
        }
@@ -1119,7 +1119,7 @@
            return $db;
        }
        if (is_null($value)
        if ((null === $value)
            || ($value === '' && $db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)
        ) {
            if (!$quote) {
@@ -1128,7 +1128,7 @@
            return 'NULL';
        }
        if (is_null($type)) {
        if (null === $type) {
            switch (gettype($value)) {
            case 'integer':
                $type = 'integer';
@@ -1288,9 +1288,15 @@
     */
    function _quoteLOB($value, $quote, $escape_wildcards)
    {
        $db =& $this->getDBInstance();
        if (PEAR::isError($db)) {
            return $db;
        }
        if ($db->options['lob_allow_url_include']) {
        $value = $this->_readFile($value);
        if (PEAR::isError($value)) {
            return $value;
            }
        }
        return $this->_quoteText($value, $quote, $escape_wildcards);
    }
@@ -1554,7 +1560,7 @@
     */
    function _retrieveLOB(&$lob)
    {
        if (is_null($lob['value'])) {
        if (null === $lob['value']) {
            $lob['value'] = $lob['resource'];
        }
        $lob['loaded'] = true;
@@ -1687,21 +1693,32 @@
        }
        $match = '';
        if (!is_null($operator)) {
        if (null !== $operator) {
            $operator = strtoupper($operator);
            switch ($operator) {
            // case insensitive
            case 'ILIKE':
                if (is_null($field)) {
                if (null === $field) {
                    return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
                        'case insensitive LIKE matching requires passing the field name', __FUNCTION__);
                }
                $db->loadModule('Function', null, true);
                $match = $db->function->lower($field).' LIKE ';
                break;
            case 'NOT ILIKE':
                if (null === $field) {
                    return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
                        'case insensitive NOT ILIKE matching requires passing the field name', __FUNCTION__);
                }
                $db->loadModule('Function', null, true);
                $match = $db->function->lower($field).' NOT LIKE ';
                break;
            // case sensitive
            case 'LIKE':
                $match = is_null($field) ? 'LIKE ' : $field.' LIKE ';
                $match = (null === $field) ? 'LIKE ' : ($field.' LIKE ');
                break;
            case 'NOT LIKE':
                $match = (null === $field) ? 'NOT LIKE ' : ($field.' NOT LIKE ');
                break;
            default:
                return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
@@ -1713,9 +1730,6 @@
            if ($key % 2) {
                $match.= $value;
            } else {
                if ($operator === 'ILIKE') {
                    $value = strtolower($value);
                }
                $escaped = $db->escape($value);
                if (PEAR::isError($escaped)) {
                    return $escaped;