Bruce Gust
asked on
What does this formatting equate to?
I'm replacing some deprecated code and I've encountered something I don't recognize. It's the formatting of a particular result and I'm needing someone to help me figure out what this result will look like:
The $result is an integer, but what does "0,0" do?
In a similar vein, what does this formatting do:
$result, 0, email - what's that?
Same thing with the following three results.
Thanks!
$query="Select registrationeventid from tblregistrationeventtoscreening where screeningperiodid in (select screeningperiodid from tblscreeningsubperiod where screeningsubperiodid = $screeningsubperiodid)";
$result=mssql_query($query,$con);
$registrationeventid=mssql_result($result,0,0);
The $result is an integer, but what does "0,0" do?
In a similar vein, what does this formatting do:
$query="select email,fn,ln,dob from onecommunity.dbo.tblparticipant where participantid=$participantid";
$result=mssql_query($query,$con);
$email=mssql_result($result,0,'email');
$fn=processApostrophe(mssql_result($result,0,'fn'));
$ln=processApostrophe(mssql_result($result,0,'ln'));
$dob=mssql_result($result,0,'dob');
$result, 0, email - what's that?
Same thing with the following three results.
Thanks!
ASKER
I'm not moving the database, just retooling the code from Procedural mssql to PDO / OOP.
Thanks so much for getting back with me. I went out to the manual, but it didn't make a whole lot of sense. Let me try to explain this back to you:
What mssql_result does is assert the equivalent to an IF statement in order to ensure some kind of value, even if there isn't a value in the first row of the query, correct?
If that's true, can you break down what the three values are?
$registrationeventid=mssql _result($r esult,0,0) ;
$registrationeventid is going to be whatever was returned in $result. But if nothing was returned, the value will be "0." Thing is, you've got three entities in ($result, 0,0). What's the second "0" represent?
Thanks!
Thanks so much for getting back with me. I went out to the manual, but it didn't make a whole lot of sense. Let me try to explain this back to you:
What mssql_result does is assert the equivalent to an IF statement in order to ensure some kind of value, even if there isn't a value in the first row of the query, correct?
If that's true, can you break down what the three values are?
$registrationeventid=mssql
$registrationeventid is going to be whatever was returned in $result. But if nothing was returned, the value will be "0." Thing is, you've got three entities in ($result, 0,0). What's the second "0" represent?
Thanks!
Sorry, I should have said "database access code".
The 3 parameters are:
1. The query resource returned from the query
2. The row number from the result-set that you want to access.
3. the column number or name from the row that you want to extract.
mysql_result() returns "something" from the query resource... it returns one piece of information from the query results if the query was successful, or it returns false otherwise.
Yeah, I find the PHP official documentation a bit obtuse at times, too.
The 3 parameters are:
1. The query resource returned from the query
2. The row number from the result-set that you want to access.
3. the column number or name from the row that you want to extract.
mysql_result() returns "something" from the query resource... it returns one piece of information from the query results if the query was successful, or it returns false otherwise.
Yeah, I find the PHP official documentation a bit obtuse at times, too.
I forgot to add that since you're going with OOP style coding and PDO, you might want to create a Database Class for all the accessor logic... much easier than sprinkling it all around your PHP logic. There are a few of them freely available around the net or you could write your own so you get a good feel for using PDO. The bigger the project (or the greater the number of programs to re-code) the more useful and time-saving it becomes.
ASKER
Actually, it's not an IF statement...
I'm looking at the manual as well as some other resources and it's basically a systemic way of retrieving one value from a recordset.
http://php.net/manual/kr/function.mssql-result.php
http://www.w3resource.com/php/function-reference/mysql_result.php
"...The mysql_result() is used to fetch the contents of a single field from a mysql query. "
Yes?
The three values are:
result - the query
row - the row number (row numbers start at 0)
field - the column heading of the query you're running. It can be an alias or an offset. Generally, you'll assign it a numeric value because it's quicker.
So, what you've got is a code that specifies the query, the row number (0) and the column heading offset. Taken together, you're returning the contents of a single field from your query
I'm looking at the manual as well as some other resources and it's basically a systemic way of retrieving one value from a recordset.
http://php.net/manual/kr/function.mssql-result.php
http://www.w3resource.com/php/function-reference/mysql_result.php
"...The mysql_result() is used to fetch the contents of a single field from a mysql query. "
Yes?
The three values are:
result - the query
row - the row number (row numbers start at 0)
field - the column heading of the query you're running. It can be an alias or an offset. Generally, you'll assign it a numeric value because it's quicker.
So, what you've got is a code that specifies the query, the row number (0) and the column heading offset. Taken together, you're returning the contents of a single field from your query
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bring it!
$registrationeventid=mssql
$result should contain the result-resource of the select query if it was successful, or 0 if it
wasn't successful.
$registrationeventid=mssql
would assign the value of the first column of the first row from the query to $registrationeventid (if it was successful).
Similarly, these 3 statements would retrieve the columns named "email", "fn" and "ln" from the first
row of the query if it was successful.
$email=mssql_result($resul
$fn=processApostrophe(mssq
$ln=processApostrophe(mssq
You are apparently migrating your older PHP code to version 7, but what daabase code are you moving to?
mysqli, pdo, ado... which one?