Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Could you check my logic on this, please?

Posted on 2016-07-27
3
Medium Priority
?
71 Views
Last Modified: 2016-07-27
The dealbreaker, at this point, is the presence of an array. At least, that's what I've been able to deduce thus far.

Here's the first part of the process:

protected function processStatementSql ($sql) {

        $statements = StatementImage::runQuery($sql);
        $ret = array();

        //Second and Third DB Calls
        //TXN TABLE STUFF
        // NOTE - I don't know there is a reason to process these as separate queries
        // and I think they can be reasonably combined with the query held in getSQL()
        // and processed through to get the same dataset more quickly.
        if ($statements) {
            foreach($statements as $st) {
                $accountid = $st['AccountID'];

                if (!$st['StatementRollUp'] || $st['templateid'] == '9') {
                    $st['newtxns'] = StatementImage::getNewTransactions($st, $st['showphysician'] == '1');
                } else {
                    $st['newtxns'] = array();
                }

Open in new window


Look at line 15. $statements is a SELECT statement that's just been fired. We're going to parse it out as an array and when we get to $st['StatementRollUp'] we pause and ask a question...

if (!$st['StatementRollUp'] || $st['templateid'] == '9') {

Which, in plain language is asking, if the StatementRollUp value is not defined OR the template id is 9, then proceed with the getNewTransactions method. At which point, you've defining an index within an array ($st['newtxns'])  as the values represented by the getNewTransactions method.

Otherwise...

You've got the $st['newtxns'] array, but there's nothing in it.

The very next line of the code is this:

foreach($st['newtxns'] as $txn){
                    $st['lastclaimdate'] = $txn['firstdos'] < $st['lastclaimdate'] || $st['lastclaimdate'] === null ? $txn['firstdos'] : $st['lastclaimdate'];
                }

Open in new window


So, now that $st['newtxns'] is $txn.

I know. It's a mess. But be that as it may, I've been hired to fix what's there and not write new code. There's six years worth of original programming and the layers of nonsense are eternal.

So, here comes that $txn array and it's being looked at in the context of another IF statement:

  if (isset($encounter['txns'])) {

From here, the PDF that's being generated is formatted according to the result of this IF statement. My thought is that if your $encounter['txns'] array is devoid of content, then the result of the above IF clause is FALSE.

Agreed?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 59

Assisted Solution

by:Julian Hansen
Julian Hansen earned 600 total points
ID: 41731577
Think of it like this isset will return true if $encounter['txns'] exists i.e. if $encounter is an array AND index 'txns' is defined.

If $encounter is not an array or does not have an index 'txns' set, then isset will return false
0
 

Author Comment

by:brucegust
ID: 41731647
So...

It doesn't have anything to do with content. If both the array and the index have been defined, then this:

 if (isset($encounter['txns'])) {

...is TRUE. Both the array and the index have been defined and what's IN the array is not what's being looked at as much as it's THAT it's an array.

Yes?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1400 total points
ID: 41731696
It doesn't have anything to do with content...

Not quite.  Variables may have been defined, then subsequently set to NULL or unset().  PHP isset() determines if a variable is set and is not NULL.  It returns TRUE if both cases are true for all of its arguments.

There really isn't any such thing as "devoid of content" unless you make an assignment of NULL to a variable.  And to fully understand what is happening to the PHP symbol table, you need to know the scope of the variables.

In the case of the $encounter array, it can be defined like this, but one of its member positions remains undefined:
<?php // demo/temp_brucegust.php
/**
 * https://www.experts-exchange.com/questions/28959883/Could-you-check-my-logic-on-this-please.html
 *
 * http://php.net/manual/en/function.var-dump.php
 * http://php.net/manual/en/function.error-reporting.php
 */

// WITH FULL ERROR REPORTING -- ALWAYS RECOMMENDED
error_reporting(E_ALL);

$encounter = [];
var_dump($encounter);
if (isset($encounter)) echo "encounter is defined";
if (isset($encounter['txns'])) echo "encounter.txns is defined";

Open in new window

Outputs:
array(0) { } encounter is defined

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question