Solved

Could you check my logic on this, please?

Posted on 2016-07-27
3
61 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 57

Assisted Solution

by:Julian Hansen
Julian Hansen earned 150 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 110

Accepted Solution

by:
Ray Paseur earned 350 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

751 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