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


PHP ArrayIterator::key方法代码示例

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


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

示例1: search

 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:32,代码来源:SearchEngine.php

示例2: test_constructor_iterator_immutability

 /**
  * @coversNothing
  */
 public function test_constructor_iterator_immutability()
 {
     $value = new \ArrayIterator([1, 2, 3, 4, 5]);
     $value->next();
     $prevKey = $value->key();
     new testSubject($value);
     self::assertSame($prevKey, $value->key());
 }
开发者ID:rkgladson,项目名称:PHPixme,代码行数:11,代码来源:SeqTest.php

示例3: addToQuote

 public function addToQuote()
 {
     $iterator = new \ArrayIterator($this->_data['fixture']['addresses']);
     while ($iterator->valid()) {
         if ($iterator->key() == 'billing_and_shipping') {
             $this->_setBillingAndShipping();
         } else {
             $this->_setBillingOrShipping($iterator->key());
         }
         $iterator->next();
     }
 }
开发者ID:ctasca,项目名称:magefix,代码行数:12,代码来源:ShippingAddress.php

示例4: seek

 /**
  * {@inheritdoc}
  */
 public function seek($offset)
 {
     $newIterator = new \ArrayIterator($this->baseArray);
     while ($newIterator->key() != $offset && $newIterator->valid()) {
         $newIterator->next();
     }
     if (!$newIterator->valid()) {
         throw new BadOffsetException("OffsetProvider is not valid", 550);
     }
     if ($newIterator->key() != $offset) {
         throw new \Exception("Something went wrong", 550);
     }
     $this->arrayIterator = $newIterator;
 }
开发者ID:macseem,项目名称:mim,代码行数:17,代码来源:DataArray.php

示例5: key

 /**
  * Return the pathname for the current resource.
  *
  * @return string The path to the temporary resource or null if no resource exists.
  */
 public function key()
 {
     if (!$this->valid()) {
         return null;
     }
     return $this->iterator->key();
 }
开发者ID:mohiva,项目名称:common,代码行数:12,代码来源:TempResourceContainer.php

示例6: processStatesItr

 public function processStatesItr(ArrayIterator $statesItr)
 {
     // ArrayIterator
     for ($statesItr; $statesItr->valid(); $statesItr->next()) {
         echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL;
     }
 }
开发者ID:jestintab,项目名称:zendphp,代码行数:7,代码来源:typehinting_exm1.php

示例7: update

 /**
  * Update = $sql = "UPDATE tabla SET campo1 = ?, campo2 = ?, campo3 = ?
  * WHERE idcampo = ?"
  * $stm->bindValue(4, idValor);  
  */
 public function update($table, $data, $where, $id)
 {
     $result = null;
     $iterator = new ArrayIterator($data);
     $sql = "UPDATE {$table} SET ";
     while ($iterator->valid()) {
         $sql .= $iterator->key() . " = ?, ";
         $iterator->next();
     }
     //Se elimina los dos ultimos caracteres (la coma y el espacio)
     $sql = substr($sql, 0, -2);
     $sql .= " WHERE {$where} = ?";
     $stm = $this->_getDbh()->prepare($sql);
     $i = 1;
     foreach ($iterator as $param) {
         $stm->bindValue($i, $param);
         $i++;
     }
     /**
      * Se asigna el bindValue para el parametro $id, como no esta contemplado en los ciclos del $data,
      * se asigna en la posicion ($iterator->count()+1) y se le asigna el tipo de dato: PDO::PARAM_INT 
      */
     $stm->bindValue($iterator->count() + 1, $id, PDO::PARAM_INT);
     $result = $stm->execute();
     return $result;
 }
开发者ID:paarma,项目名称:BibliotecaFupWeb,代码行数:31,代码来源:DbCrud.php

示例8: zroneClassLoader

/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
开发者ID:zrone,项目名称:apiDocument,代码行数:30,代码来源:zroneFrameWork.php

示例9: __construct

 /**
  * @param \ArrayIterator $map
  */
 public function __construct(\ArrayIterator $map)
 {
     $this->map = $map;
     parent::__construct($this->map, function ($element) use($map) {
         return array($map->key(), $element);
     });
 }
开发者ID:alexeyshockov,项目名称:colada,代码行数:10,代码来源:ArrayIteratorPairs.php

示例10: getById

 /**
  *
  *@param $id_ciu
  *
  *
  **/
 public function getById($id_jefe)
 {
     $this->conex = DataBase::getInstance();
     //Consulta SQL
     $consulta = "SELECT * FROM FISC_JEFE_OFICINA WHERE \n\t\t\t\t\t\tID_JEFE=:id_jefe";
     $stid = oci_parse($this->conex, $consulta);
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id_jefe', $id_jefe);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     $result = array();
     // Obtener los resultados de la consulta
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         $alm = new Denuncia();
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
         $result[] = $alm;
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $result;
 }
开发者ID:vanckruz,项目名称:draftReports,代码行数:41,代码来源:model_jefe_oficina.php

示例11: key

 /**
  * Returns the identifier of the current cache entry pointed to by the cache
  * entry iterator.
  *
  * @return string
  * @api
  */
 public function key()
 {
     if ($this->cacheEntriesIterator === null) {
         $this->rewind();
     }
     return $this->cacheEntriesIterator->key();
 }
开发者ID:neos,项目名称:flow-development-collection,代码行数:14,代码来源:PdoBackend.php

示例12: each

 /**
  * iterate the complete data collection and execute callback for each key => value pair passing the key
  * and the value to the callback function/method as first and second parameter. the callback must be
  * a valid callable that can be executed call_user_func_array
  *
  * @error 16307
  * @param callable $callback expects the callback function/method
  * @return void
  */
 public function each(callable $callback)
 {
     while ($this->iterator->valid()) {
         call_user_func_array($callback, array($this->iterator->key(), $this->iterator->current()));
         $this->iterator->next();
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:16,代码来源:Container.php

示例13: getById

 public function getById($id)
 {
     $this->conex = DataBase::getInstance();
     $stid = oci_parse($this->conex, "SELECT *\n\t\t\tFROM FISC_CIUDADANO WHERE ID_CIUDADANO=:id");
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id', $id);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Obtener los resultados de la consulta
     $alm = new FiscCiudadano();
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         while ($it->valid()) {
             $alm->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $alm;
 }
开发者ID:vanckruz,项目名称:draftReports,代码行数:31,代码来源:class_fisc_ciudadanoDAO.php

示例14: queryByIC

 /**
  *
  *@param $id_ciu
  *
  *
  **/
 public function queryByIC($id_ciu)
 {
     $this->conex = DataBase::getInstance();
     $stid = oci_parse($this->conex, "SELECT * FROM TBL_REPRESENTANTEEMPRESAS WHERE CLV_REPRESENTANTE=:id_ciu");
     if (!$stid) {
         $e = oci_error($this->conex);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     // Realizar la lógica de la consulta
     oci_bind_by_name($stid, ':id_ciu', $id_ciu);
     $r = oci_execute($stid);
     if (!$r) {
         $e = oci_error($stid);
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
     $result = new RepresentanteEmpresa();
     // Obtener los resultados de la consulta
     while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $it = new ArrayIterator($fila);
         while ($it->valid()) {
             $result->__SET(strtolower($it->key()), $it->current());
             $it->next();
         }
     }
     //Libera los recursos
     oci_free_statement($stid);
     // Cierra la conexión Oracle
     oci_close($this->conex);
     //retorna el resultado de la consulta
     return $result;
 }
开发者ID:vanckruz,项目名称:draftReports,代码行数:37,代码来源:model_representante.php

示例15: getByPosition

 /**
  * Gets item by it`s position
  * @param integer $position
  * @return mixed
  */
 private function getByPosition($position)
 {
     $key = $this->_list->key();
     $this->_list->seek($position);
     $item = $this->_list->current();
     $this->_list->seek($key);
     return $item;
 }
开发者ID:colonB,项目名称:Copycat,代码行数:13,代码来源:CollectionAbstract.php


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