当前位置: 首页>>代码示例>>PHP>>正文


PHP DBObject::DB方法代码示例

本文整理汇总了PHP中DBObject::DB方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::DB方法的具体用法?PHP DBObject::DB怎么用?PHP DBObject::DB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObject的用法示例。


在下文中一共展示了DBObject::DB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDB

 function getDB()
 {
     $this->db = new ImpPDO('sqlite:' . $this->TempFile);
     $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     DBObject::$DB = $this->db;
     ImpSQLBuilder::$DB = $this->db;
 }
开发者ID:acdha,项目名称:impphp,代码行数:7,代码来源:DBObject_Tests.php

示例2: __construct

 protected function __construct($ID = false)
 {
     assert(!empty($this->Properties));
     assert(!isset($this->_classOverrides));
     assert(!isset($this->RequiredFormFields));
     assert(!isset($this->FormFields));
     if (!empty($GLOBALS['DB'])) {
         DBObject::$DB = $GLOBALS['DB'];
     }
     if (!empty($ID)) {
         if (is_array($ID)) {
             $this->setProperties($ID);
             $this->_initialValues = $ID;
         } else {
             $ID = intval($ID);
             if (empty($ID)) {
                 throw new InvalidArgumentException(get_class($this) . " constructor called with empty id {$ID}");
             }
             $Q = self::$DB->query($this->_generateSelect($this->DBTable, $this->Properties, "ID={$ID}"));
             if (count($Q) < 1) {
                 throw new InvalidArgumentException(get_class($this) . " constructor called with ID {$ID} which is not in {$this->DBTable}");
             } else {
                 assert(count($Q) == 1);
                 $this->ID = $ID;
                 $this->setProperties($Q[0]);
                 $this->_initialValues = $Q[0];
             }
         }
     } else {
         foreach ($this->Properties as $Name => $def) {
             if (is_array($def)) {
                 assert(isset($def['type']));
                 $Type = $def['type'];
             } else {
                 $Type = $def;
             }
             if (is_array($def) and array_key_exists('default', $def)) {
                 $this->{$Name} = $def['default'];
             } else {
                 switch ($Type) {
                     case 'date':
                     case 'datetime':
                     case 'timestamp':
                     case 'integer':
                         $this->{$Name} = (int) 0;
                         break;
                     case 'double':
                     case 'currency':
                         $this->{$Name} = (double) 0;
                     case 'string':
                     case 'enum':
                         $this->{$Name} = '';
                         break;
                     case 'set':
                         $this->{$Name} = array();
                         break;
                     case 'collection':
                         break;
                     case 'object':
                         // TODO: this breaks __set(), presumably due to a recursive call: $this->$Name = null;
                         break;
                     case 'boolean':
                         $this->{$Name} = false;
                         break;
                     default:
                         throw new InvalidArgumentException('No default for property of type ' . $Type);
                 }
             }
             $this->_initialValues[$Name] = $this->{$Name};
         }
     }
 }
开发者ID:acdha,项目名称:impphp,代码行数:72,代码来源:DBObject.php


注:本文中的DBObject::DB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。