Hi all,
I was wondering if anyone mught be able to suggest a more elegant solution to a coding requirement.
I am doing a DB::Query() to pull two fields from a country database, based on user input - specifically a region code for two countries.
Then Im using another DB::Query using those region codes to pull further values from a second table.
Im currently doing this as follows:
Start
$sql = "SELECT regioncode FROM country
WHERE ((printable_name = '$origin') OR (printable_name = '$destination'))";
$rr = DB::Query($sql);
// With the array $data derived from the above - then iterate through the array using foreach and populating to further variables $regcode0 and $regcode1
// I then use those variables in the next mysql query.
$i = 0;
while( $data = $rr-> fetchAssoc() ){
foreach ($data as $value) {
${'regcode' . $i} = $value;
$i++;
}
}
$selector = " ((regioncode = '$regcode0') OR (regioncode = '$regcode1')) ";
}
$rs = DB::Select("providers", $selector);
Ends
I feel sure that I should be able to do this and keep the data in the array and pass it to DB::Select or DB::Query
Is there a more elegant way of doing this? Note that the array has two identical keys - regioncode.
Lastly (but possibly related, I cant get my head round the practical difference between DB::Select and DB::Query - can someone enlighten me?
Thanks in advance!
Geoff.