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


PHP Set::insert方法代码示例

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


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

示例1: edit

 function edit($id = null)
 {
     if (!$id && empty($this->data)) {
         $this->Session->setFlash(__('Invalid ResultLookup', true));
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->data)) {
         parent::archive($id);
         $this->data = Set::insert($this->data, 'ResultLookup.user_id', $this->Auth->user('id'));
         if ($this->ResultLookup->save($this->data)) {
             $this->Session->setFlash(__('The ResultLookup has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The ResultLookup could not be saved. Please, try again.', true));
         }
     }
     if (empty($this->data)) {
         $this->data = $this->ResultLookup->read(null, $id);
         $test_id = $this->data['ResultLookup']['test_id'];
         $this->set('test_id', $test_id);
         $this->set('id', $id);
     }
     $tests = $this->ResultLookup->Test->find('list');
     $this->set(compact('tests'));
 }
开发者ID:kenners,项目名称:uamuzi-bora,代码行数:25,代码来源:result_lookups_controller.php

示例2: write

 /**
  * Used to store a dynamic variable in the Configure instance.
  *
  * Usage:
  * {{{
  * Configure::write('One.key1', 'value of the Configure::One[key1]');
  * Configure::write(array('One.key1' => 'value of the Configure::One[key1]'));
  * Configure::write('One', array(
  *     'key1' => 'value of the Configure::One[key1]',
  *     'key2' => 'value of the Configure::One[key2]'
  * );
  *
  * Configure::write(array(
  *     'One.key1' => 'value of the Configure::One[key1]',
  *     'One.key2' => 'value of the Configure::One[key2]'
  * ));
  * }}}
  *
  * @link http://book.cakephp.org/view/926/write
  * @param array $config Name of var to write
  * @param mixed $value Value to set for var
  * @return boolean True if write was successful
  * @access public
  */
 public static function write($config, $value = null)
 {
     $_this =& Configure::getInstance();
     if (!is_array($config)) {
         $config = array($config => $value);
     }
     foreach ($config as $name => $value) {
         if (strpos($name, '.') === false) {
             $_this->{$name} = $value;
         } else {
             $names = explode('.', $name, 4);
             switch (count($names)) {
                 case 2:
                     $_this->{$names[0]}[$names[1]] = $value;
                     break;
                 case 3:
                     $_this->{$names[0]}[$names[1]][$names[2]] = $value;
                     break;
                 case 4:
                     $names = explode('.', $name, 2);
                     if (!isset($_this->{$names[0]})) {
                         $_this->{$names[0]} = array();
                     }
                     $_this->{$names[0]} = Set::insert($_this->{$names[0]}, $names[1], $value);
                     break;
             }
         }
     }
     return true;
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:54,代码来源:configure.php

示例3: write

 /**
  * Permet d'écrire une donnée dans la session
  *
  * @param varchar $key Clée de la donnée
  * @param mixed $value Donnée à écrire
  * @return boolean Vrai si la valeur est insérée, faux sinon
  * @access	static
  * @author	koéZionCMS
  * @version 0.1 - 30/12/2011
  * @see /Koezion/lib/set.php
  */
 static function write($key, $value)
 {
     $session = Set::insert($_SESSION, $key, $value);
     //On insère les données et on récupère la nouvelle variable de session
     $_SESSION = $session;
     //On affecte les données à la variable de session
     return Set::classicExtract($_SESSION, $key) === $value;
     //On retourne le résultat de la fonction
 }
开发者ID:strifefrosst,项目名称:koeZionCMS,代码行数:20,代码来源:session.php

示例4: write

 /**
  * @param string $path
  * @param mixed $data
  * @param bool $forUser
  * @return void
  */
 public function write($path = '', $data, $forUser = true)
 {
     if (!$path) {
         return;
     }
     $path = $this->_getPath($path, $forUser);
     $__cookie = $this->_getGummCookie();
     if (strpos($path, '.') === false) {
         $__cookie[$path] = $data;
     } else {
         $__cookie = Set::insert($__cookie, $path, $data);
     }
     $this->_storeGummCookie($__cookie);
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:20,代码来源:cookie.php

示例5: _parseTrueToDefault

 function _parseTrueToDefault($config)
 {
     $_this =& CaptchaConfig::getInstance();
     $trueToDefault = Set::normalize($_this->trueToDefault);
     foreach ($trueToDefault as $path => $options) {
         if (Set::extract($path, $config) === true) {
             if (empty($options)) {
                 $options = Set::extract($path, $_this->defaultConfig);
             }
             $config = Set::insert($config, $path, $options);
         }
     }
     return $config;
 }
开发者ID:kevthunder,项目名称:cake-captcha,代码行数:14,代码来源:captcha_config.php

示例6: afterFind

 /**
  * After find callback
  * @param $result array
  * @result $result array
  */
 function afterFind($results)
 {
     $results2[0]['Preference'] = Configure::read('Preference');
     $skip = array('user_id', 'created', 'modified', 'id');
     foreach ($results[0]['Preference'] as $key => $value) {
         if (isset($value) && !is_null($value)) {
             if (!in_array($key, $skip)) {
                 $key = str_replace('_', '.', $key);
                 $results2[0]['Preference'] = Set::insert($results2[0]['Preference'], $key, $value);
             } else {
                 $results2[0]['Preference'][$key] = $value;
             }
         }
     }
     return $results2;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:21,代码来源:preference.php

示例7: extractHierarchicMulti

 function extractHierarchicMulti($pathsAssoc, $data = null, $options = array())
 {
     $defaultOptions = array('extractNull' => true);
     $options = array_merge($defaultOptions, $options);
     $res = array();
     foreach ($pathsAssoc as $name => $paths) {
         $val = SetMulti::extractHierarchic($paths, $data, $options);
         if (!is_null($val) || $options['extractNull']) {
             if (is_numeric($name)) {
                 $res[$name] = $val;
             } else {
                 $res = Set::insert($res, $name, $val);
             }
         }
     }
     return $res;
 }
开发者ID:kevthunder,项目名称:cake-custom-filter,代码行数:17,代码来源:set_multi.php

示例8: connect

 /**
  * Connects to the database. Options are specified in the $config instance variable.
  *
  * @return boolean Connected.
  * @throws MissingConnectionException
  */
 public function connect()
 {
     if ($this->connected !== true) {
         if (Set::check($this->config, 'login')) {
             $this->config = Set::insert($this->config, 'request.uri.user', Set::get($this->config, 'login'));
         }
         if (Set::check($this->config, 'password')) {
             $this->config = Set::insert($this->config, 'request.uri.pass', Set::get($this->config, 'password'));
         }
         try {
             $this->Socket = new HttpSocket($this->config);
             $this->connected = true;
         } catch (SocketException $e) {
             throw new MissingConnectionException(array('class' => $e->getMessage()));
         }
     }
     return $this->connected;
 }
开发者ID:riddhisoni1324,项目名称:cakephp_fxchng,代码行数:24,代码来源:CouchDBSource.php

示例9: add

 /**
  * Add a menu item
  *
  * @param string $path dot separated path in the array.
  * @param array $options menu options array
  * @return void
  */
 public static function add($path, $options)
 {
     $pathE = explode('.', $path);
     $pathE = array_splice($pathE, 0, count($pathE) - 2);
     $parent = join('.', $pathE);
     if (!empty($parent) && !Set::check(self::$_items, $parent)) {
         $title = Inflector::humanize(end($pathE));
         $o = array('title' => $title);
         self::_setupOptions($o);
         self::add($parent, $o);
     }
     self::_setupOptions($options);
     $current = Set::extract($path, self::$_items);
     if (!empty($current)) {
         self::_replace(self::$_items, $path, $options);
     } else {
         self::$_items = Set::insert(self::$_items, $path, $options);
     }
 }
开发者ID:romaing,项目名称:croogo-rg,代码行数:26,代码来源:CroogoNav.php

示例10: calcAllFormAResults

 function calcAllFormAResults($sub_num = null)
 {
     $allFormAResults = null;
     $allTeachers = $this->query("select id,username,name from users as User where group_id=2");
     $i = 1;
     foreach ($allTeachers as $teacher) {
         $teachersResults = $this->calcFormAResults($teacher['User']['id'], $sub_num);
         if (!is_string($teachersResults) && isset($teachersResults)) {
             foreach ($teachersResults as $teachersResult) {
                 if (!is_string($teachersResult)) {
                     $teachersResult['teacherUserName'] = $teacher['User']['username'];
                     $teachersResult['teacherName'] = $teacher['User']['name'];
                     $allFormAResults = Set::insert($allFormAResults, $i++, $teachersResult);
                 }
             }
         }
     }
     //debug($allFormAResults);
     return $allFormAResults;
 }
开发者ID:raveebhat,项目名称:app,代码行数:20,代码来源:form_a_record.php

示例11: edit

 function edit($id = null)
 {
     if (!$id && empty($this->data)) {
         $this->Session->setFlash(__('Invalid Test', true));
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->data)) {
         parent::archive($id);
         $this->data = Set::insert($this->data, 'Test.user_id', $this->Auth->user('id'));
         if ($this->Test->save($this->data)) {
             $this->Session->setFlash(__('The Test has been saved', true));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The Test could not be saved. Please, try again.', true));
         }
     }
     if (empty($this->data)) {
         $this->data = $this->Test->read(null, $id);
     }
 }
开发者ID:kenners,项目名称:uamuzi-bora,代码行数:20,代码来源:tests_controller.php

示例12: get_vol_horaire_a_attribuer_with_loop

 function get_vol_horaire_a_attribuer_with_loop($id = 'all')
 {
     // Méthode 3
     if ($id == null or $id == 'all') {
         // à l'aide d'une requête find all et d'une boucle
         $temp = $this->find('all');
         $result = array();
         foreach ($temp as $key => $matiere) {
             $matiere_id = $matiere['Matiere']['id'];
             $result = Set::insert($result, $matiere_id, array('h_cours' => $matiere['Matiere']['h_cours'], 'h_td' => $matiere['Matiere']['h_td'] * $matiere['Filiere']['nb_gr_td'], 'h_tp' => $matiere['Matiere']['h_tp'] * $matiere['Filiere']['nb_gr_tp']));
         }
         return $result;
     } else {
         // à l'aide d'une requête read recursive et du calcul heure_matiere*nb_gr
         $this->recursive = 0;
         $matiere = $this->read(null, $id);
         $result = array('h_cours' => $matiere['Matiere']['h_cours'], 'h_td' => $matiere['Matiere']['h_td'] * $matiere['Filiere']['nb_gr_td'], 'h_tp' => $matiere['Matiere']['h_tp'] * $matiere['Filiere']['nb_gr_tp']);
         return $result;
     }
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:20,代码来源:matiere.php

示例13: getBilanServiceWithSqlView

 function getBilanServiceWithSqlView($id = 'all')
 {
     //  Méthode 1 : à l'aide d'une vue SQL dans la base
     $this->VuePersosBilanServices =& ClassRegistry::init('VuePersosBilanServices');
     $this->VuePersosBilanServices->recursive = -1;
     if ($id == 'all' or $id == null) {
         $temp = $this->VuePersosBilanServices->find('all');
         // ToDo : mettre en forme l'array pour avoir perso_id comme clé
         //$temp=Set::combine($temp, '{n}.VuePersosBilanServices.id', '{n}.VuePersosBilanServices.h_tp');
         $result = array();
         foreach ($temp as $key => $matieresperso) {
             //debug($result($matieresperso['VuePersosBilanServices']['id'])=1);
             //$result($matieresperso['VuePersosBilanServices']['id'])=$matieresperso['VuePersosBilanServices']['h_cours'];
             $result = Set::insert($result, $matieresperso['VuePersosBilanServices']['id'], array('h_cours' => $matieresperso['VuePersosBilanServices']['h_cours'], 'h_td' => $matieresperso['VuePersosBilanServices']['h_td'], 'h_tp' => $matieresperso['VuePersosBilanServices']['h_tp']));
         }
         return $result;
         //return $temp;
     } else {
         $temp = $this->VuePersosBilanServices->read(null, $id);
         return $temp['VuePersosBilanServices'];
     }
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:22,代码来源:perso.php

示例14: __combine_array

 function __combine_array($arr1, $arr2)
 {
     $number = count($arr1);
     // find the first index for the next result
     foreach ($arr2 as $element2) {
         $test = true;
         foreach ($arr1 as $element1) {
             if ($element1 == $element2) {
                 $test = false;
                 break;
             }
         }
         if ($test) {
             $arr1 = Set::insert($arr1, '\\' . $number, $element2);
         }
         $number += 1;
     }
     return $arr1;
 }
开发者ID:kenners,项目名称:uamuzi-bora,代码行数:19,代码来源:app_controller.php

示例15: write

 /**
  * Writes value to given session variable name.
  *
  * @param mixed $name Name of variable
  * @param string $value Value to write
  * @return boolean True if the write was successful, false if the write failed
  * @access public
  */
 public function write($name, $value)
 {
     if (empty($name)) {
         return false;
     }
     if (in_array($name, $this->watchKeys)) {
         trigger_error(sprintf(__('Writing session key {%s}: %s', true), $name, Debugger::exportVar($value)), E_USER_NOTICE);
     }
     $this->__overwrite($_SESSION, Set::insert($_SESSION, $name, $value));
     return Set::classicExtract($_SESSION, $name) === $value;
 }
开发者ID:radig,项目名称:CakeMongoSession,代码行数:19,代码来源:cake_mongo_session.php


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