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


PHP Collection::Add方法代码示例

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


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

示例1: Take

 public function Take($count)
 {
     $result = new Collection();
     $currentCount = 0;
     foreach ($this->m_items as $item) {
         $result->Add($item);
         $currentCount++;
         if ($currentCount == $count) {
             break;
         }
     }
     return $result;
 }
开发者ID:bonahona,项目名称:ShellMvc,代码行数:13,代码来源:SqlCollection.php

示例2: getCarrinho

 /**
  * RETORNA UMA COLEÇÂO COM OS PRODUTOS DO CARRINHO
  * @param $nomeIndiceArraySessao (É importante que esse parâmetro tenha a mesma ordem do da string)
  * @return Collection();
  */
 public function getCarrinho($nomeIndiceArraySessao)
 {
     $colecao = new Collection();
     $arraySession = explode('#', substr($_SESSION[$this->nomeSessao], 0, -1));
     $arrayItem = array();
     if (count($arraySession) > 0) {
         foreach ($arraySession as $key => $value) {
             if ($value != '') {
                 $arrayItem = explode('|', $value);
                 foreach ($nomeIndiceArraySessao as $keySecundario => $value) {
                     $item[$value] = $arrayItem[$keySecundario];
                 }
                 $item['key'] = $key;
                 $colecao->Add($item);
             }
         }
     }
     return $colecao;
 }
开发者ID:alanansilva,项目名称:3heads,代码行数:24,代码来源:Carrinho.php

示例3: All

 public function All($modelCollection)
 {
     $result = new Collection();
     $tableName = $modelCollection->ModelCache['MetaData']['TableName'];
     $columns = array_keys($modelCollection->ModelCache['Columns']);
     $sqlStatement = "SELECT * FROM {$tableName}";
     if (!($preparedStatement = $this->Database->prepare($sqlStatement))) {
         echo "Failed to prepare PDO statement";
         var_dump($this->Database->errorInfo());
     }
     $preparedStatement->execute();
     $fields = array();
     foreach ($columns as $column) {
         $name = $column;
         ${$name} = null;
         $fields[$name] =& ${$name};
     }
     foreach ($preparedStatement as $row) {
         $item = new $modelCollection->ModelName($modelCollection);
         $item->FlagAsSaved();
         foreach ($fields as $key => $value) {
             $item->{$key} = $row[$key];
         }
         $result->Add($item);
     }
     return $result;
 }
开发者ID:bonahona,项目名称:ShellMvc,代码行数:27,代码来源:PdoDatabase.php

示例4: All

 public function All($modelCollection)
 {
     $result = new Collection();
     $tableName = $modelCollection->ModelCache['MetaData']['TableName'];
     $columns = array_keys($modelCollection->ModelCache['Columns']);
     $sqlStatement = "SELECT * FROM {$tableName}";
     if (!($preparedStatement = $this->Database->prepare($sqlStatement))) {
         echo $this->Database->error;
     }
     $preparedStatement->execute();
     if (!($meta = $preparedStatement->result_metadata())) {
         return null;
     }
     $fields = array();
     foreach ($columns as $column) {
         $name = $column;
         ${$name} = null;
         $fields[$name] =& ${$name};
     }
     call_user_func_array(array($preparedStatement, 'bind_result'), $fields);
     while ($preparedStatement->fetch()) {
         $item = new $modelCollection->ModelName($modelCollection);
         $item->FlagAsSaved();
         foreach ($fields as $key => $value) {
             $item->{$key} = $value;
         }
         $result->Add($item);
     }
     $preparedStatement->close();
     return $result;
 }
开发者ID:bonahona,项目名称:ShellMvc,代码行数:31,代码来源:MySqliDatabase.php

示例5: getCollection

 /**
  * 
  * Execulta uma consulta sql e retorna uma coleção
  * @param String $sql
  * @param Array $optionsField
  * @param Boolean $debug
  * @return Collection()
  */
 public static function getCollection($sql, $optionsField = '', $debug = false)
 {
     try {
         self::$rs = self::getExecute($sql)->fetchAll(PDO::FETCH_ASSOC);
         $colecao = new Collection();
         foreach (self::$rs as $row) {
             $obj = array();
             foreach ($row as $key => $value) {
                 /**
                  * VERIFICA SE EXISTE OPÇÕES PARA O CAMPO
                  */
                 if (!empty($optionsField) && !empty($value)) {
                     if (array_key_exists($key, $optionsField) && !empty($value)) {
                         $fieldValue = self::getFormatField($key, $optionsField, $value);
                     } else {
                         $fieldValue = $value;
                     }
                     $obj[$key] = $fieldValue;
                 } else {
                     $obj[$key] = $value;
                 }
             }
             if (!empty($debug)) {
                 self::getDebugArray($obj, $debug);
             }
             $colecao->Add($obj);
         }
         unset($optionsField);
         unset($key);
         unset($value);
         unset($sql);
         unset($obj);
         return $colecao;
     } catch (Exception $e) {
         self::getMsgErro($sql);
     }
 }
开发者ID:alanansilva,项目名称:threads,代码行数:45,代码来源:DBSql.php

示例6: AddSeason

 /**
  * @return void
  * @param Season $o_season
  * @param bool $b_is_working
  * @desc Adds a season to the end of the competition
  */
 public function AddSeason(Season $o_season, $b_is_working = false)
 {
     $o_season->SetCompetition($this);
     $i_index = parent::Add($o_season);
     if ($b_is_working or $this->i_working_index == -1) {
         $this->SetWorkingIndex($i_index);
     }
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:14,代码来源:competition.class.php

示例7: Collection

    $Url['Onglet'] = 'FilmsParAnnee';
} else {
    $Url['Onglet'] = $_REQUEST['Onglet'];
}
// =====================================================================================================================================================
// Préparation des données à fournir à la vue : Le tableau $Vue
// =====================================================================================================================================================
$nbFilm = Bd::GetNbfilms();
$nbGenre = Bd::GetNbGenres();
$nbFilmAnnee = Bd::GetNbFilmsParAnnee();
$nbFilmGenre = Bd::GetNbFilmsParGenre();
$lesStatsAnnee = new Collection();
$lesStatsGenre = new Collection();
foreach ($nbFilmAnnee as $tuple) {
    $Stat = new Statistique($tuple['Annee'], $tuple['NbFilm']);
    $lesStatsAnnee->Add($Stat);
}
foreach ($nbFilmGenre as $tuple) {
    $Stat = new Statistique($tuple['LibelleGenre'], $tuple['NbFilm']);
    $lesStatsGenre->Add($Stat);
}
$Vue['NbFilms'] = $nbFilm;
$Vue['NbGenre'] = $nbGenre;
$Vue['Onglet'] = $Url['Onglet'];
$Vue['StatsAnnee'] = $lesStatsAnnee;
$Vue['StatsGenre'] = $lesStatsGenre;
$Infos['Page']['ContenuAvecEncarts'] = VueFilm::GetXhtmlStatistiques($Vue);
// =====================================================================================================================================================
// Création d'une page en lui passant en paramètre le tableau $Infos. Si ce n'est pas fait, une page "standard" sera créée par défaut dans le contrôleur principal
// =====================================================================================================================================================
$Page = new PageAvecEncartsGaucheDroite($Infos);
开发者ID:amstr4d,项目名称:Cinepassion,代码行数:31,代码来源:ctrl.Statistiques.inc.php


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