Solved

Could you check my logic on this, please?

Posted on 2016-07-27
3
67 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 58

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

626 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