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


PHP CostbenefitprojectionHelper::setAsset方法代码示例

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


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

示例1: postSaveHook


//.........这里部分代码省略.........
             // Select all records in scaling factors the belong to this company
             $query->select($db->quoteName(array('id', 'causerisk', 'published')));
             $query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
             $query->where($db->quoteName('company') . ' = ' . (int) $validData['id']);
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
                 // load the scaling factors already set
                 $already = $db->loadObjectList();
                 $publish = array();
                 $archive = array();
                 $bucket = array();
                 foreach ($already as $scale) {
                     if (CostbenefitprojectionHelper::checkArray($validData['causesrisks'])) {
                         if (in_array($scale->causerisk, $validData['causesrisks']) && $scale->published != 1) {
                             // publish the scaling factor (update)
                             $publish[$scale->id] = $scale->id;
                         } elseif (!in_array($scale->causerisk, $validData['causesrisks'])) {
                             // archive the scaling factor (update)
                             $archive[$scale->id] = $scale->id;
                         }
                         $bucket[] = $scale->causerisk;
                     } else {
                         // archive the scaling factor (update)
                         $archive[$scale->id] = $scale->id;
                     }
                 }
                 // update the needed records
                 $types = array('publish' => 1, 'archive' => 2);
                 foreach ($types as $type => $int) {
                     if (CostbenefitprojectionHelper::checkArray(${$type})) {
                         foreach (${$type} as $id) {
                             $query = $db->getQuery(true);
                             // Fields to update.
                             $fields = array($db->quoteName('published') . ' = ' . (int) $int);
                             // Conditions for which records should be updated.
                             $conditions = array($db->quoteName('id') . ' = ' . (int) $id);
                             $query->update($db->quoteName('#__costbenefitprojection_scaling_factor'))->set($fields)->where($conditions);
                             $db->setQuery($query);
                             $db->execute();
                         }
                     }
                 }
             }
             if (CostbenefitprojectionHelper::checkArray($validData['causesrisks'])) {
                 // remove those already set from the saved list of causesrisks
                 if (CostbenefitprojectionHelper::checkArray($bucket)) {
                     $insert = array();
                     foreach ($validData['causesrisks'] as $causerisk) {
                         if (!in_array($causerisk, $bucket)) {
                             $insert[] = $causerisk;
                         }
                     }
                 } else {
                     $insert = $validData['causesrisks'];
                 }
             }
             // insert the new records
             if (CostbenefitprojectionHelper::checkArray($insert)) {
                 $created = $db->quote(JFactory::getDate()->toSql());
                 $created_by = JFactory::getUser()->get('id');
                 $company = $validData['id'];
                 // Create a new query object.
                 $query = $db->getQuery(true);
                 // Insert columns.
                 $columns = array('causerisk', 'company', 'mortality_scaling_factor_females', 'mortality_scaling_factor_males', 'presenteeism_scaling_factor_females', 'presenteeism_scaling_factor_males', 'yld_scaling_factor_females', 'yld_scaling_factor_males', 'published', 'created_by', 'created');
                 // setup the values
                 $values = array();
                 foreach ($insert as $new) {
                     $array = array($new, $company, 1, 1, 1, 1, 1, 1, 1, $created_by, $created);
                     $values[] = implode(',', $array);
                 }
                 // Prepare the insert query.
                 $query->insert($db->quoteName('#__costbenefitprojection_scaling_factor'))->columns($db->quoteName($columns))->values(implode('), (', $values));
                 // Set the query using our newly populated query object and execute it.
                 $db->setQuery($query);
                 $done = $db->execute();
                 if ($done) {
                     // we must set the assets
                     foreach ($insert as $causerisk) {
                         // get all the ids. Create a new query object.
                         $query = $db->getQuery(true);
                         $query->select($db->quoteName(array('id')));
                         $query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
                         $query->where($db->quoteName('causerisk') . ' = ' . (int) $causerisk);
                         $query->where($db->quoteName('company') . ' = ' . (int) $company);
                         $db->setQuery($query);
                         $db->execute();
                         if ($db->getNumRows()) {
                             $aId = $db->loadResult();
                             // make sure the access of asset is set
                             CostbenefitprojectionHelper::setAsset($aId, 'scaling_factor');
                         }
                     }
                 }
             }
         }
     }
     return;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:company.php

示例2: save


//.........这里部分代码省略.........
                         if ('version' == $target[$key]) {
                             $cell = (int) $version + 1;
                         }
                         // verify publish authority
                         if ('published' == $target[$key] && !$canState) {
                             continue;
                         }
                         // set to update array
                         if (in_array($key, $data['target_headers']) && is_numeric($cell)) {
                             $fields[] = $db->quoteName($target[$key]) . ' = ' . $cell;
                         } elseif (in_array($key, $data['target_headers']) && is_string($cell)) {
                             $fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell);
                         } elseif (in_array($key, $data['target_headers']) && is_null($cell)) {
                             // if import data is null then set empty
                             $fields[] = $db->quoteName($target[$key]) . " = ''";
                         }
                     }
                     // load the defaults
                     $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
                     $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
                     // Conditions for which records should be updated.
                     $conditions = array($db->quoteName('id') . ' = ' . $id);
                     $query->update($db->quoteName('#__costbenefitprojection_' . $table))->set($fields)->where($conditions);
                     $db->setQuery($query);
                     $db->execute();
                 } elseif ($canCreate) {
                     // insert item
                     $query = $db->getQuery(true);
                     // reset all buckets
                     $columns = array();
                     $values = array();
                     $version = false;
                     // Insert columns. Insert values.
                     foreach ($row as $key => $cell) {
                         // ignore column
                         if ('IGNORE' == $target[$key]) {
                             continue;
                         }
                         // remove id
                         if ('id' == $target[$key]) {
                             continue;
                         }
                         // update created
                         if ('created_by' == $target[$key]) {
                             continue;
                         }
                         // update created
                         if ('created' == $target[$key]) {
                             continue;
                         }
                         // Make sure the alias is incremented
                         if ('alias' == $target[$key]) {
                             $cell = $this->getAlias($cell, $table);
                         }
                         // update version
                         if ('version' == $target[$key]) {
                             $cell = 1;
                             $version = true;
                         }
                         // set to insert array
                         if (in_array($key, $data['target_headers']) && is_numeric($cell)) {
                             $columns[] = $target[$key];
                             $values[] = $cell;
                         } elseif (in_array($key, $data['target_headers']) && is_string($cell)) {
                             $columns[] = $target[$key];
                             $values[] = $db->quote($cell);
                         } elseif (in_array($key, $data['target_headers']) && is_null($cell)) {
                             // if import data is null then set empty
                             $columns[] = $target[$key];
                             $values[] = "''";
                         }
                     }
                     // load the defaults
                     $columns[] = 'created_by';
                     $values[] = $db->quote($user->id);
                     $columns[] = 'created';
                     $values[] = $db->quote($todayDate);
                     if (!$version) {
                         $columns[] = 'version';
                         $values[] = 1;
                     }
                     // Prepare the insert query.
                     $query->insert($db->quoteName('#__costbenefitprojection_' . $table))->columns($db->quoteName($columns))->values(implode(',', $values));
                     // Set the query using our newly populated query object and execute it.
                     $db->setQuery($query);
                     $done = $db->execute();
                     if ($done) {
                         $aId = $db->insertid();
                         // make sure the access of asset is set
                         CostbenefitprojectionHelper::setAsset($aId, $table);
                     }
                 } else {
                     return false;
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:import.php


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