本文整理汇总了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");
}
示例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());
}
示例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();
}
}
示例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;
}
示例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();
}
示例6: processStatesItr
public function processStatesItr(ArrayIterator $statesItr)
{
// ArrayIterator
for ($statesItr; $statesItr->valid(); $statesItr->next()) {
echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL;
}
}
示例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;
}
示例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();
}
}
}
示例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);
});
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}