Bruce Gust
asked on
The combo of an array and a construct. Is this right?
I'm trying to debug a page and as part of that process, I'm encountering a brand of syntax I don't typically write and I'm needing to deconstruct things in order to better understand it.
There's a function that appears to be creating an array. That array is referenced in the construct at the top of the page, or at least that appears to be the case. Tell me if this is right:
At the top of the page, you have this:
Further down, you've got this:
//processing
$results = StatementImage::processSta tementSql( $sql);
//Create Objects
$return = array();
foreach($results as $pipe_delim) {
$return[] = new StatementImage($pipe_delim );
}
Is this correct:
$results - the data that's coming back from the SELECT statement represented by StatementImage::processSta tementSql( $sql);
$return = array(); - setting up an array
foreach($results as $pipe_delim) {
$return[] = new StatementImage($pipe_delim );
} - this is packing all of the data in $results into an array called $return...
This is where I start to get a little hesitant. I'm accustomed to something like this:
while($row=$query->fetch_a rray())
{
$result_array[]=$row;
}
What is $StatementImage($pipe_deli m)?
There's a function that appears to be creating an array. That array is referenced in the construct at the top of the page, or at least that appears to be the case. Tell me if this is right:
At the top of the page, you have this:
class StatementImage {
protected $statementid;
protected $pipe_delim;
protected $statement_data;
protected static $debug = false;
/**
* Takes the pipe delimited file and creates a statementimage entity.
*/
public function __construct($pipe_delim) {
$this->pipe_delim = $pipe_delim;
$this->statement_data = StatementImage::pipeToArray($pipe_delim);
$this->statementid = str_replace('T', '', $this->statement_data['statement']['statement_pin']);
}
Further down, you've got this:
//processing
$results = StatementImage::processSta
//Create Objects
$return = array();
foreach($results as $pipe_delim) {
$return[] = new StatementImage($pipe_delim
}
Is this correct:
$results - the data that's coming back from the SELECT statement represented by StatementImage::processSta
$return = array(); - setting up an array
foreach($results as $pipe_delim) {
$return[] = new StatementImage($pipe_delim
} - this is packing all of the data in $results into an array called $return...
This is where I start to get a little hesitant. I'm accustomed to something like this:
while($row=$query->fetch_a
{
$result_array[]=$row;
}
What is $StatementImage($pipe_deli
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ray, I agree with you! But this isn't my app and I'm not in a place, nor would it be appropriate for me, to rewrite the code. I'm on contract to simply plug some holes until the client moves to an entirely different software. I'm just trying to understand what's there, however convoluted it may be, so I can make some repairs and then watch this whole application fade into the sunset when the client migrates over to a new application.
I'm re-reading my question and I've decided it's probably not fair in that I've got several questions packed into one. Furthermore, I think I've got what I need based on your input as well as zephyr and Kim. That being the fact that you can pack an array, even a multi-dimensional array, into a property. Hadn't seen that before and wanted to confirm it. I think that's been done here.
As always, thanks for your time, gentlemen!
I'm re-reading my question and I've decided it's probably not fair in that I've got several questions packed into one. Furthermore, I think I've got what I need based on your input as well as zephyr and Kim. That being the fact that you can pack an array, even a multi-dimensional array, into a property. Hadn't seen that before and wanted to confirm it. I think that's been done here.
As always, thanks for your time, gentlemen!
ASKER
I appreciate your time! I've got the entire StatementImage.php page below. I'm taking your comments and attempting to retrace the logic of "$pipe_delim" throughout. Let me know if this is right.
Open in new window
I) We're kicking things off by establishing three properties: $statementid, $pipe_delim and $statement_data. I'm not ignoring $debug, I'm just not including it at this point because it's not really doing anything significant from a programmatic standpoint.
II) Construct, by definition, is assigning values to the properties that were just mentioned. What's significant is that all three values are based off of what's coming in via whatever is in the $pipe_delim value. (Right?)
III) The entire machinery of StatementImage.php is put into motion with another page that calls the "load" function that's located on line 394. Within that function you're constructing a SELECT statement (statement.php - I don't have that included) using other function within the StatementImage class. You run that SELECT at line 406 and at line 411, you pack all of the results into the $pipe_delim property. This is actually kind of clever because now you can efficiently move all of the results of your SELECT throughout your class without having to run the same SELECT statement over and over again. (Right?)
IV) Finally, the $pipe_delim property, now stuffed with the results from the load query, is now being broken down into the pdf content thanks to the pipeToArray function referenced on line 26 and documented on lines 66-238. [b}(Right?)[/b]
Thanks!