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


PHP DataGenerator::getFieldValueFromDataContainer方法代碼示例

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


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

示例1: setDefaultValues

 /**
  * This method checks if there is any data prepared for record or it uses
  * default data based on type of the field.
  *
  * It looks for data for each field in record in following order:
  * 1. Checks if data is set in DataObject
  * 2. Checks data from data container (@see setData())
  * 3. Checks data from $defaultValues variables defined in each DataObject
  * 4. Generate data based on type of the field
  *
  * It populates primary keys fields only if data for key field was specifically
  * set using any of methods defined in 1, 2 or 3 (it doesn't
  * populate it with default data based on field type)
  *
  * @param DataObject $do    DataObject to populate data in
  * @param int $counter      Used to generate a key for data container array to retreive data
  * @access package private
  * @static
  */
 function setDefaultValues(&$do, $counter = 0)
 {
     $fields = $do->table();
     $keys = $do->keys();
     $table = $do->getTableWithoutPrefix();
     foreach ($fields as $fieldName => $fieldType) {
         if (!isset($do->{$fieldName})) {
             if (!empty($this) && is_a($this, 'DataGenerator')) {
                 $fieldValue = $this->getFieldValueFromDataContainer($table, $fieldName, $counter);
             } else {
                 $fieldValue = DataGenerator::getFieldValueFromDataContainer($table, $fieldName, $counter);
             }
             if (!isset($fieldValue) && !in_array($fieldName, $keys)) {
                 $fieldValue = DataGenerator::defaultValueForObject($do, $fieldName, $fieldType);
                 if (!isset($fieldValue)) {
                     $fieldValue = DataGenerator::defaultValueByType($fieldType);
                 }
             }
             if (isset($fieldValue)) {
                 if ($fieldValue != OA_DATAOBJECT_DEFAULT_NULL) {
                     // exception for NULLs
                     $do->{$fieldName} = $fieldValue;
                 }
             }
         }
     }
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:46,代碼來源:DataGenerator.php


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