/** * *@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; }
/** * @dataProvider provideCases */ function testCases(array $insert, $limit, array $expect) { $iterator = new ArrayIterator($insert); $limited = $iterator->limit($limit); $this->assertCount(count($expect), $limited); $this->assertEquals($expect, $limited->toArray()); }
/** * @dataProvider provideCases */ function testCases(array $insert, callable $map, array $expect) { $iterator = new ArrayIterator($insert); $mapped = $iterator->map($map); $this->assertCount(count($expect), $mapped); $this->assertEquals($expect, $mapped->toArray()); }
public function execute(InputInterface $input, OutputInterface $output) { $configuration = new Configuration(file_get_contents(__DIR__ . '/../../../config/config.json')); $resolver = new SpawnResolver($configuration, CpuInfo::detect()); $factory = new Factory(); $classname = $resolver->getClassName(); if ($input->getOption('verbose')) { $outputLogger = new StreamHandler('php://stdout'); } else { $outputLogger = new NullHandler(); } $workers = new \ArrayIterator(); for ($i = 1; $i <= $resolver->getSpawnQuantity(); $i++) { $output->write("Launching Worker <info>{$i}</info> ..."); $logger = new Logger('Worker-' . $i); $logger->pushHandler($outputLogger); $logger->pushHandler(new RotatingFileHandler(__DIR__ . '/../../../logs/worker-' . $i . '.logs', 3)); $worker = new Worker('Worker-' . $i, new \GearmanWorker(), $logger); foreach ($configuration['gearman-servers'] as $server) { $worker->addServer($server['host'], $server['port']); } $worker->setFunction(new $classname($configuration, $logger, $factory)); $workers->append($worker); $output->writeln("Success !"); } $manager = new ProcessManager(new EventDispatcher()); $manager->process($workers, function (Worker $worker) { $worker->run(); }); }
/** * @expectedException \X\ConfigManager\Exception\PropertyNotExistsException * @expectedExceptionMessageRegExp ~.*?X\\Test\\MappingClass\\RootElement.*?nonExistProperty.*?~ * * @throws \X\ConfigManager\Exception\PropertyNotExistsException */ public function testInitWithWrongProperty() { $rootElement = new RootElement(); $rootElementWrongConfig = $this->rootElementConfig->getArrayCopy(); $rootElementWrongConfig['content']['nonExistProperty'] = true; $rootElement->initialize($rootElementWrongConfig['content']); }
public function processStatesItr(ArrayIterator $statesItr) { // ArrayIterator for ($statesItr; $statesItr->valid(); $statesItr->next()) { echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL; } }
/** * Helper method for recursively building a parse tree. * * @param ArrayIterator $tokens Stream of tokens * * @return array Token parse tree * * @throws LogicException when nesting errors or mismatched section tags are encountered. */ private function _buildTree(ArrayIterator $tokens) { $stack = array(); do { $token = $tokens->current(); $tokens->next(); if ($token === null) { continue; } else { switch ($token[Handlebars_Tokenizer::TYPE]) { case Handlebars_Tokenizer::T_END_SECTION: $newNodes = array(); $continue = true; do { $result = array_pop($stack); if ($result === null) { throw new LogicException('Unexpected closing tag: /' . $token[Handlebars_Tokenizer::NAME]); } if (!array_key_exists(Handlebars_Tokenizer::NODES, $result) && isset($result[Handlebars_Tokenizer::NAME]) && $result[Handlebars_Tokenizer::NAME] == $token[Handlebars_Tokenizer::NAME]) { $result[Handlebars_Tokenizer::NODES] = $newNodes; $result[Handlebars_Tokenizer::END] = $token[Handlebars_Tokenizer::INDEX]; array_push($stack, $result); break 2; } else { array_unshift($newNodes, $result); } } while (true); break; default: array_push($stack, $token); } } } while ($tokens->valid()); return $stack; }
/** * USU5 function to return the base filename */ function usu5_base_filename() { // Probably won't get past SCRIPT_NAME unless this is reporting cgi location $base = new ArrayIterator(array('SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL')); while ($base->valid()) { if (array_key_exists($base->current(), $_SERVER) && !empty($_SERVER[$base->current()])) { if (false !== strpos($_SERVER[$base->current()], '.php')) { // ignore processing if this script is not running in the catalog directory if (dirname($_SERVER[$base->current()]) . '/' != DIR_WS_HTTP_CATALOG) { return $_SERVER[$base->current()]; } preg_match('@[a-z0-9_]+\\.php@i', $_SERVER[$base->current()], $matches); if (is_array($matches) && array_key_exists(0, $matches) && substr($matches[0], -4, 4) == '.php' && (is_readable($matches[0]) || false !== strpos($_SERVER[$base->current()], 'ext/modules/'))) { return $matches[0]; } } } $base->next(); } // Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php if ($_SERVER['SCRIPT_NAME'] == '/' || $_SERVER['PHP_SELF'] == '/') { return HTTP_SERVER; } trigger_error('USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING); }
public function matchesList(array $items) { $itemIterator = new \ArrayIterator($items); $matcherIterator = new \ArrayIterator($this->getMatchers()); $currentMatcher = null; if ($matcherIterator->valid()) { $currentMatcher = $matcherIterator->current(); } while ($itemIterator->valid() && null !== $currentMatcher) { $hasMatch = $currentMatcher->matches($itemIterator->current()); if ($hasMatch) { $matcherIterator->next(); if ($matcherIterator->valid()) { $currentMatcher = $matcherIterator->current(); } else { $currentMatcher = null; } } $itemIterator->next(); } //echo sprintf("%s->%s, %s->%s\n", $itemIterator->key(), $itemIterator->count(), // $matcherIterator->key(), $matcherIterator->count()); if (null !== $currentMatcher && !$currentMatcher->matches(null)) { $this->reportFailed($currentMatcher); return false; } $matcherIterator->next(); return $this->matchRemainder($matcherIterator); }
public function setUp() { $data = <<<ENDXML <permcheck> <excludes> <file>excluded/file5.txt</file> <dir>excluded2</dir> </excludes> <executables> <file>file1.sh</file> <file>file3.sh</file> </executables> </permcheck> ENDXML; $this->config = \Mockery::mock(new Config()); $this->loader = \Mockery::mock(new XmlLoader($data, $this->config)); $this->fileSystem = \Mockery::mock(new Filesystem($this->config, '/does/not/exist')); $files = new \ArrayIterator(); $mocks = array('/does/not/exist/file1.sh' => array(true, false), '/does/not/exist/file2.txt' => array(false, false), '/does/not/exist/file3.sh' => array(false, false), '/does/not/exist/file4.txt' => array(true, false), '/does/not/exist/excluded/file5.txt' => array(true, false), '/does/not/exist/excluded2/file6.sh' => array(false, false), '/does/not/exist/symlink' => array(true, true)); foreach ($mocks as $file => $properties) { /** @var MockInterface|\SplFileInfo $file */ $file = \Mockery::mock(new \SplFileInfo($file)); $file->shouldReceive('getName')->andReturn($file); $file->shouldReceive('isExecutable')->andReturn($properties[0]); $file->shouldReceive('isLink')->andReturn($properties[1]); $files->append($file); } $this->fileSystem->shouldReceive('getFiles')->andReturn($files); $this->messageBag = \Mockery::mock(new Bag()); $this->reporter = \Mockery::mock(new XmlReporter()); $this->permCheck = new PermCheck($this->loader, $this->config, $this->fileSystem, $this->messageBag, $this->reporter, '/does/not/exist'); }
/** * @param string $collection * @param array $query * * @return \Iterator */ public function find($collection, array $query = []) { $cursor = $this->getDatabase()->selectCollection($collection)->find($query); $iterator = new \ArrayIterator($cursor); $iterator->rewind(); return $iterator; }
/** * Helper method for recursively building a parse tree. * * @param \ArrayIterator $tokens Stream of tokens * * @throws \LogicException when nesting errors or mismatched section tags * are encountered. * @return array Token parse tree * */ private function _buildTree(\ArrayIterator $tokens) { $stack = array(); do { $token = $tokens->current(); $tokens->next(); if ($token !== null) { switch ($token[Tokenizer::TYPE]) { case Tokenizer::T_END_SECTION: $newNodes = array(); do { $result = array_pop($stack); if ($result === null) { throw new \LogicException('Unexpected closing tag: /' . $token[Tokenizer::NAME]); } if (!array_key_exists(Tokenizer::NODES, $result) && isset($result[Tokenizer::NAME]) && $result[Tokenizer::NAME] == $token[Tokenizer::NAME]) { $result[Tokenizer::NODES] = $newNodes; $result[Tokenizer::END] = $token[Tokenizer::INDEX]; array_push($stack, $result); break; } else { array_unshift($newNodes, $result); } } while (true); // There is no break here, since we need the end token to handle the whitespace trim // There is no break here, since we need the end token to handle the whitespace trim default: array_push($stack, $token); } } } while ($tokens->valid()); return $stack; }
public function __construct() { parent::__construct(); $this->setTemplate('mpbackup/backup/js/loglevel.phtml'); $this->_logLevelIterator = new ArrayObject(self::$LOG_LEVELS); $this->_logLevelIterator = $this->_logLevelIterator->getIterator(); }
/** * @param \Iterator $operatorChain * @param \Iterator $input * * @return \ArrayIterator */ private function solveIntermediateOperationChain(\Iterator $operatorChain, \Iterator $input) { $results = new \ArrayIterator(); $input->rewind(); $continueWIthNextItem = true; while ($input->valid() && $continueWIthNextItem) { $result = $input->current(); $useResult = true; // do the whole intermediate operation chain for the current input $operatorChain->rewind(); while ($operatorChain->valid() && $useResult) { /** @var IntermediateOperationInterface $current */ $current = $operatorChain->current(); // apply intermediate operations $result = $current->apply($result, $input->key(), $useResult, $returnedCanContinue); // track the continuation flags $continueWIthNextItem = $continueWIthNextItem && $returnedCanContinue; // iterate $operatorChain->next(); } if ($useResult) { $results->append($result); } // goto next item $input->next(); } return $results; }
/** * AJAX action: Check access rights for creation of a submailbox. * * Variables used: * - all: (integer) If 1, return all mailboxes. Otherwise, return only * INBOX, special mailboxes, and polled mailboxes. * * @return string HTML to use for the folder tree. */ public function smartmobileFolderTree() { $ftree = $GLOBALS['injector']->getInstance('IMP_Ftree'); /* Poll all mailboxes on initial display. */ $this->_base->queue->poll($ftree->poll->getPollList(), true); $iterator = new AppendIterator(); /* Add special mailboxes explicitly. INBOX should appear first. */ $special = new ArrayIterator(); $special->append($ftree['INBOX']); foreach (IMP_Mailbox::getSpecialMailboxesSort() as $val) { if (isset($ftree[$val])) { $special->append($ftree[$val]); } } $iterator->append($special); /* Now add polled mailboxes. */ $filter = new IMP_Ftree_IteratorFilter($ftree); $filter->add(array($filter::CONTAINERS, $filter::REMOTE, $filter::SPECIALMBOXES)); if (!$this->vars->all) { $filter->add($filter::POLLED); } $filter->mboxes = array('INBOX'); $iterator->append($filter); return $ftree->createTree($this->vars->all ? 'smobile_folders_all' : 'smobile_folders', array('iterator' => $iterator, 'render_type' => 'IMP_Tree_Jquerymobile'))->getTree(true); }
/** * Default constructor to load the iterator. Override the parent * LimitIterator as we don't want to return * * @access public * @param ArrayIterator $it */ public function __construct(ArrayIterator $it, $page = 1, $limit = 10) { $this->_it = $it; $this->_count = $it->count(); $this->setCurrentPage($page); $this->setItemsPerPage($limit); }
function printer(ArrayIterator $iterator){ while($iterator->valid()){ print_r($iterator->current()); echo "<br /><br />"; $iterator->next(); } }
/** @return php.Iterator */ protected function nextIterator() { if ($this->source >= sizeof($this->sources)) { return null; } $src = $this->sources[$this->source]; // Evaluate lazy supplier functions if ($src instanceof \Closure) { $src = $src(); } if ($src instanceof \Iterator) { $it = $src; } else { if ($src instanceof \Traversable) { $it = new \IteratorIterator($src); } else { if ($src instanceof XPIterator) { $it = new XPIteratorAdapter($src); } else { if (is_array($src)) { $it = new \ArrayIterator($src); } else { if (null === $src) { $it = new \ArrayIterator([]); } else { throw new IllegalArgumentException('Expecting either an iterator, iterable, an array or NULL'); } } } } } $this->source++; $it->rewind(); return $it; }
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; }
public function ProcceedToPayment() { include_once "models/FlightModel.php"; $flightId = Request::RequestParams("flightid"); $category = Request::RequestParams("ticketcategory"); $children = Request::RequestParams("children"); $adults = Request::RequestParams("adults"); $typeticket = Request::RequestParams("typeticket"); //set the booking details $booking = new BookInfo(); $booking->adult_no = isset($adults) ? $adults : 0; $booking->children_no = isset($children) ? $children : 0; $booking->flight_id = $flightId; $booking->ticket_cat = $category; $booking->ticket_type = $typeticket; $flightModel = new FlightModel(); $this->viewModel->flightDbModel = $flightModel; $this->viewModel->flight = $flightModel->GetFlightById($flightId); if ($booking->validated()) { if ($this->viewModel->flight != NULL) { $booking->ticket_adult_price = $this->viewModel->flight->ticketPrice; } } else { //else still required more informations $attr = new ArrayIterator(); $attr->offsetSet("class", "warning"); $attr->offsetSet("style", "border:1px solid #000;"); ContextManager::ValidationFor("warning", $booking->getError()); } $this->ViewBag("Title", "Booking"); $this->ViewBag("Controller", "Booking"); $this->ViewBag("Page", "Flight"); Session::set("BOOKINFO", $booking); return $this->View($this->viewModel, "Home", "Index"); }
/** * Switches to alternate nicks as needed when nick collisions occur. * * @return void */ public function onResponse() { // If no alternate nick list was found, return if (empty($this->iterator)) { return; } // If the response event indicates that the nick set is in use... $code = $this->getEvent()->getCode(); if ($code == Phergie_Event_Response::ERR_NICKNAMEINUSE) { // Attempt to move to the next nick in the alternate nick list $this->iterator->next(); // If another nick is available... if ($this->iterator->valid()) { // Switch to the new nick $altNick = $this->iterator->current(); $this->doNick($altNick); // Update the connection to reflect the nick change $this->getConnection()->setNick($altNick); } else { // If no other nicks are available... // Terminate the connection $this->doQuit('All specified alternate nicks are in use'); } } }
protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1) { $output = ""; $rownumber = 0; foreach ($rows as $row) { if ($row->cols) { $columns = array(); foreach ($row->cols as $col) { $nextcontent = $splitcontent->current(); $isholder = !isset($col->rows); if ($isholder) { $splitcontent->next(); //advance iterator if there are no sub-rows $pos++; //wrap split content in a HTMLText object $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content"); $dbObject->setOptions(array("shortcodes" => true)); $nextcontent = $dbObject; } $width = $col->width ? (int) $col->width : 1; //width is at least 1 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null)); } $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template); } else { //every row should have columns!! } } return $output; }
/** * 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; }
public function testConstructor() { // array input $input = []; $this->mock->expects($this->at(0))->method('setOptions')->with($this->equalTo($input)); $class = new \ReflectionClass(self::CLASSNAME); $ctor = $class->getConstructor(); $ctor->invoke($this->mock, $input); // traversable input $input = new \ArrayIterator([]); $this->mock->expects($this->at(0))->method('setOptions')->with($this->equalTo($input->getArrayCopy())); $ctor->invoke($this->mock, $input); // string input $input = 'adapter'; $this->mock->expects($this->at(0))->method('setAdapter')->with($this->equalTo($input)); $ctor->invoke($this->mock, $input); // adapter input $input = $this->getMockForAbstractClass('Conversio\\ConversionAlgorithmInterface'); $this->mock->expects($this->at(0))->method('setAdapter')->with($this->equalTo($input)); $ctor->invoke($this->mock, $input); // null input $input = null; $this->mock->expects($this->never())->method('setAdapter')->with($this->equalTo($input)); $this->mock->expects($this->never())->method('setOptions')->with($this->equalTo($input)); $ctor->invoke($this->mock, $input); }
/** * * @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"); }
/** * Assert that the given commands have been dispatched in the exact sequence provided. * * @param array $expected The commands expected to have been published on the bus * @throws GovernorAssertionError */ public function assertDispatchedEqualTo(array $expected = array()) { $actual = $this->commandBus->getDispatchedCommands(); if (count($expected) !== count($actual)) { throw new GovernorAssertionError(sprintf("Got wrong number of commands dispatched. Expected <%s>, got <%s>", count($expected), count($actual))); } $actualIterator = new \ArrayIterator($actual); $expectedIterator = new \ArrayIterator($expected); $counter = 0; while ($actualIterator->valid()) { $actualItem = $actualIterator->current(); $expectedItem = $expectedIterator->current(); if ($expectedItem instanceof CommandMessageInterface) { if ($expectedItem->getPayloadType() !== $actualItem->getPayloadType()) { throw new GovernorAssertionError(sprintf("Unexpected payload type of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getPayloadType(), $actualItem->getPayloadType())); } $this->assertCommandEquality($counter, $expectedItem->getPayloadType(), $actualItem->getPayload()); if ($expectedItem->getMetaData() !== $actualItem->getMetaData()) { throw new GovernorAssertionError(sprintf("Unexpected Meta Data of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getMetaData(), $actualItem->getMetaData())); } } else { $this->assertCommandEquality($counter, $expectedItem, $actualItem->getPayload()); } $counter++; $actualIterator->next(); $expectedIterator->next(); } }
public function testRetrievesAndCachesTargetData() { $ctime = strtotime('January 1, 2013'); $a = $this->getMockBuilder('SplFileinfo')->setMethods(array('getSize', 'getMTime', '__toString'))->disableOriginalConstructor()->getMock(); $a->expects($this->any())->method('getSize')->will($this->returnValue(10)); $a->expects($this->any())->method('getMTime')->will($this->returnValue($ctime)); $a->expects($this->any())->method('__toString')->will($this->returnValue('')); $b = $this->getMockBuilder('SplFileinfo')->setMethods(array('getSize', 'getMTime', '__toString'))->disableOriginalConstructor()->getMock(); $b->expects($this->any())->method('getSize')->will($this->returnValue(11)); $b->expects($this->any())->method('getMTime')->will($this->returnValue($ctime)); $a->expects($this->any())->method('__toString')->will($this->returnValue('')); $c = 0; $converter = $this->getMockBuilder('Aws\\S3\\Sync\\KeyConverter')->setMethods(array('convert'))->getMock(); $converter->expects($this->any())->method('convert')->will($this->returnCallback(function () use(&$c) { if (++$c == 1) { return 'foo'; } else { return 'bar'; } })); $targetIterator = new \ArrayIterator(array($b, $a)); $targetIterator->rewind(); $changed = new ChangedFilesIterator($targetIterator, $targetIterator, $converter, $converter); $ref = new \ReflectionMethod($changed, 'getTargetData'); $ref->setAccessible(true); $this->assertEquals(array(10, $ctime), $ref->invoke($changed, 'bar')); $this->assertEquals(array(11, $ctime), $ref->invoke($changed, 'foo')); $this->assertFalse($ref->invoke($changed, 'baz')); }
/** * *@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; }
private function setItems() { $this->items = new ArrayIterator(); foreach ($this->rss->channel->item as $onlyItem) { $item = new RssItem($onlyItem->title, $onlyItem->link, $onlyItem->pubDate, $onlyItem->description); $this->items->append($item); } }
/** * @param $locId * @return LocationHelper * @throws \Exception */ public function getLocation($locId) { if ($this->locations->offsetExists($locId)) { return $this->locations->offsetGet($locId); } else { return $this->locHelper->factory($locId); } }