[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/dbal/src/drivers/mysql/ -> lmbMysqlRecord.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/dbal/src/drivers/lmbDbBaseRecord.class.php');
  10  
  11  /**

  12   * class lmbMysqlRecord.

  13   *

  14   * @package dbal

  15   * @version $Id: lmbMysqlRecord.class.php 5945 2007-06-06 08:31:43Z pachanga $

  16   */
  17  class lmbMysqlRecord extends lmbDbBaseRecord
  18  {
  19    protected $properties = array();
  20  
  21    function __construct($data = array())
  22    {
  23      $this->properties = $data;
  24    }
  25  
  26    function get($name)
  27    {
  28      if(isset($this->properties[$name]))
  29        return $this->properties[$name];
  30    }
  31  
  32    function set($name, $value)
  33    {
  34      $this->properties[$name] = $value;
  35    }
  36  
  37    function export()
  38    {
  39      return $this->properties;
  40    }
  41  
  42    function import($values)
  43    {
  44      $this->properties = $values;
  45    }
  46  
  47    function remove($name)
  48    {
  49      if(isset($this->properties[$name]))
  50        unset($this->properties[$name]);
  51    }
  52  
  53    function has($name)
  54    {
  55      return isset($this->properties[$name]);
  56    }
  57  
  58    function reset()
  59    {
  60      $this->properties = array();
  61    }
  62  
  63    function getInteger($name)
  64    {
  65      $value = $this->get($name);
  66      return is_null($value) ?  null : (int) $value;
  67    }
  68  
  69    function getFloat($name)
  70    {
  71      $value = $this->get($name);
  72      return is_null($value) ?  null : (float) $value;
  73    }
  74  
  75    function getString($name)
  76    {
  77      $value = $this->get($name);
  78      return is_null($value) ?  null : (string) $value;
  79    }
  80  
  81    function getBoolean($name)
  82    {
  83      $value = $this->get($name);
  84      return is_null($value) ?  null : (boolean) $value;
  85    }
  86  
  87    function getIntegerTimeStamp($name)
  88    {
  89      $value = $this->get($name);
  90      if(is_integer($value))
  91        return $value;
  92      else if(is_string($value))
  93      {
  94        $ts = strtotime($value);
  95        if($ts === -1)
  96        {
  97          if(preg_match('/([\d]{4})([\d]{2})([\d]{2})([\d]{2})([\d]{2})([\d]{2})/', $value, $matches))
  98            return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
  99        }
 100        else
 101          return $ts;
 102      }
 103    }
 104  
 105    function _getDate($name, $format)
 106    {
 107      $value = $this->get($name);
 108      if(is_integer($value))
 109        return date($format, $value);
 110      else
 111        return $value;
 112    }
 113  
 114    function getStringDate($name)
 115    {
 116      return $this->_getDate($name, 'Y-m-d');
 117    }
 118  
 119    function getStringTime($name)
 120    {
 121      return $this->_getDate($name, 'H:i:s');
 122    }
 123  
 124    function getStringTimeStamp($name)
 125    {
 126      return $this->_getDate($name, 'Y-m-d H:i:s');
 127    }
 128  
 129    function getStringFixed($name)
 130    {
 131      $value = $this->get($name);
 132      return is_null($value) ?  null : (string) $value;
 133    }
 134  
 135    function getBlob($name)
 136    {
 137      return $this->get($name);
 138    }
 139  
 140    function getClob($name)
 141    {
 142      return $this->get($name);
 143    }
 144  }
 145  
 146  ?>


Generated: Tue Oct 14 04:47:40 2008 Cross-referenced by PHPXref 0.7