Copy value of variable#1 to variable #2
Posted: Tue Feb 16, 2010 8:55 am
Hello,
In order to implement a business rule, I need to save the value of a specific column found in the first row of a data set into a variable. I have no problem with the database/query aspect (thanks to the support provided by the forum yesterday). The issue arises when I transfer the returned value from one variable into another (.i.e. comment line in red below)
$dbh = new PDO("mysql:dbname=olr_master;host=localhost", "----", "-----" );
$QueryHelper = new EMail_Helper();
$sql = $QueryHelper->Query_reports_to_email_to_vetos();
$rows = $dbh->query($sql);
// we retrieve the first row from the dataset
$firstrow_vet = $rows->fetch();
// we transfer the ID of the first vet into a variable for later use
$current_vet = $firstrow_vet['Vet_ID'];
echo "1. First row ID is {$firstrow_vet['VET_ID']}<br>";
echo "2. First row ID is {$current_vet}<br>";
.....
When I run the code, the output shows that I failed transferring the value from one variable to the second. Indeed, the code returns:
1. First row ID is 990006975
2. First row ID is
Thank you,
Michel
In order to implement a business rule, I need to save the value of a specific column found in the first row of a data set into a variable. I have no problem with the database/query aspect (thanks to the support provided by the forum yesterday). The issue arises when I transfer the returned value from one variable into another (.i.e. comment line in red below)
$dbh = new PDO("mysql:dbname=olr_master;host=localhost", "----", "-----" );
$QueryHelper = new EMail_Helper();
$sql = $QueryHelper->Query_reports_to_email_to_vetos();
$rows = $dbh->query($sql);
// we retrieve the first row from the dataset
$firstrow_vet = $rows->fetch();
// we transfer the ID of the first vet into a variable for later use
$current_vet = $firstrow_vet['Vet_ID'];
echo "1. First row ID is {$firstrow_vet['VET_ID']}<br>";
echo "2. First row ID is {$current_vet}<br>";
.....
When I run the code, the output shows that I failed transferring the value from one variable to the second. Indeed, the code returns:
1. First row ID is 990006975
2. First row ID is
Thank you,
Michel