本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);