當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseObject::meta方法代碼示例

本文整理匯總了PHP中DatabaseObject::meta方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseObject::meta方法的具體用法?PHP DatabaseObject::meta怎麽用?PHP DatabaseObject::meta使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseObject的用法示例。


在下文中一共展示了DatabaseObject::meta方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: populate

 /**
  * Populates the given DatabaseObject with dummy data
  *
  * @param DatabaseObject $obj
  * @return void
  */
 protected function populate(DatabaseObject &$obj)
 {
     $meta = $obj->meta();
     $key = $meta->getKey();
     $fields = $meta->getColumnMap();
     foreach ($fields as $property => $field) {
         if ($field == $key && isset($obj->{$property})) {
             continue;
         }
         $def = $meta->getColumnDefinition($field);
         $type = strtolower(Params::generic($def, 'native_type'));
         switch ($type) {
             case 'int':
             case 'integer':
             case 'float':
             case 'currency':
             case 'decimal':
             case 'double':
             case 'real':
             case 'tinyint':
             case 'short':
             case 'long':
                 $obj->{$property} = mt_rand(0, 100);
                 break;
             case 'date':
             case 'datetime':
             case 'timestamp':
                 // Fuzz two weeks around now
                 $window = 1209600;
                 // 14 days * 24 hours * 60 minutes * 60 seconds
                 $time = time() - $window / 2 + mt_rand(0, $window);
                 if ($type == 'date') {
                     $lt = localtime($time, true);
                     $time = mktime(0, 0, 0, $lt['tm_mday'], $lt['tm_mon'] + 1, $lt['tm_year'] + 1900);
                     $lt = null;
                 }
                 $obj->{$property} = $time;
                 break;
             case 'time':
                 // range is +- 838:59:59, but since this populate thing
                 // isn't really all it could be anyhow, let's just do
                 // positive values
                 $obj->{$property} = mt_rand(1, 839 * 60 * 60 - 1);
                 break;
             case 'var_string':
                 $obj->{$property} = 'dummy string content ' . uniqid();
                 break;
             default:
                 $obj->{$property} = uniqid();
                 break;
         }
     }
 }
開發者ID:jcorbinredtree,項目名稱:framework,代碼行數:59,代碼來源:FrameworkTestCase.php

示例2: joinObject

 public function joinObject(DatabaseObject $dboA, DatabaseObject $dboB, $keyA = null, $keyB = null)
 {
     $metaA = $dboA->meta();
     $metaB = $dboB->meta();
     $tableA = $metaA->getTable();
     $tableB = $metaB->getTable();
     if (!$keyA) {
         $keyA = $metaA->getKey();
     }
     if (!$keyB) {
         $keyB = $keyA;
     }
     $sql = "INNER JOIN `{$tableB}` ON `{$tableB}`.`{$keyB}` = `{$tableA}`.`{$keyA}`";
     array_push($this->joins, $sql);
 }
開發者ID:jcorbinredtree,項目名稱:framework,代碼行數:15,代碼來源:QueryBuilder.php


注:本文中的DatabaseObject::meta方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。