Development

Changeset 10948

You must first sign up to be able to contribute.

Changeset 10948

Show
Ignore:
Timestamp:
08/19/08 16:20:41 (11 months ago)
Author:
fabien
Message:

[1.0, 1.1, 1.2] fixed 0000-00-00 dates in mysqli creole driver (closes #2234)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/vendor/creole/drivers/mysqli/MySQLiResultSet.php

    r497 r10948  
    140140        } 
    141141 
    142         if ($this->fields[$column] === null) { 
     142        if ($this->fields[$column] === null || $this->fields[$column] == '0000-00-00 00:00:00') { 
    143143            return null; 
    144144        } 
    145145 
    146146        $ts = strtotime($this->fields[$column]); 
     147 
     148    /** 
     149     * @see ResultSetCommon::getDate() 
     150     */ 
     151    public function getDate($column, $format = '%X') 
     152    { 
     153        /* As of PHP 5.2.4, strftime() returns false for '0000-00-00' which 
     154           is impossible to tell apart from illegal dates. (Pre-PHP 5.2.4 
     155           even interpreted such dates incorrectly, see  
     156           http://bugs.php.net/bug.php?id=41523). 
     157           We catch this special case and return null as the date here. 
     158           However, we need to know the exact format the DBMS returns this 
     159           date, which is why we make this decision here in the specific 
     160           driver before dispatching to the common implementation. */ 
     161        $idx = (is_int($column) ? $column - 1 : $column);         
     162        if (array_key_exists($idx, $this->fields) && $this->fields[$idx] == '0000-00-00') return null; 
     163        return parent::getDate($column, $format); 
     164    } 
    147165 
    148166        if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mysqli/MySQLiResultSet.php

    r497 r10948  
    140140        } 
    141141 
    142         if ($this->fields[$column] === null) { 
     142        if ($this->fields[$column] === null || $this->fields[$column] == '0000-00-00 00:00:00') { 
    143143            return null; 
    144144        } 
    145145 
    146146        $ts = strtotime($this->fields[$column]); 
     147 
     148    /** 
     149     * @see ResultSetCommon::getDate() 
     150     */ 
     151    public function getDate($column, $format = '%X') 
     152    { 
     153        /* As of PHP 5.2.4, strftime() returns false for '0000-00-00' which 
     154           is impossible to tell apart from illegal dates. (Pre-PHP 5.2.4 
     155           even interpreted such dates incorrectly, see  
     156           http://bugs.php.net/bug.php?id=41523). 
     157           We catch this special case and return null as the date here. 
     158           However, we need to know the exact format the DBMS returns this 
     159           date, which is why we make this decision here in the specific 
     160           driver before dispatching to the common implementation. */ 
     161        $idx = (is_int($column) ? $column - 1 : $column);         
     162        if (array_key_exists($idx, $this->fields) && $this->fields[$idx] == '0000-00-00') return null; 
     163        return parent::getDate($column, $format); 
     164    } 
    147165 
    148166        if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 
  • branches/1.2/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mysqli/MySQLiResultSet.php

    r497 r10948  
    140140        } 
    141141 
    142         if ($this->fields[$column] === null) { 
     142        if ($this->fields[$column] === null || $this->fields[$column] == '0000-00-00 00:00:00') { 
    143143            return null; 
    144144        } 
    145145 
    146146        $ts = strtotime($this->fields[$column]); 
     147 
     148    /** 
     149     * @see ResultSetCommon::getDate() 
     150     */ 
     151    public function getDate($column, $format = '%X') 
     152    { 
     153        /* As of PHP 5.2.4, strftime() returns false for '0000-00-00' which 
     154           is impossible to tell apart from illegal dates. (Pre-PHP 5.2.4 
     155           even interpreted such dates incorrectly, see  
     156           http://bugs.php.net/bug.php?id=41523). 
     157           We catch this special case and return null as the date here. 
     158           However, we need to know the exact format the DBMS returns this 
     159           date, which is why we make this decision here in the specific 
     160           driver before dispatching to the common implementation. */ 
     161        $idx = (is_int($column) ? $column - 1 : $column);         
     162        if (array_key_exists($idx, $this->fields) && $this->fields[$idx] == '0000-00-00') return null; 
     163        return parent::getDate($column, $format); 
     164    } 
    147165 
    148166        if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.