So, ok, I’m using PHP for my website, and suppose I know quite a bit of MySQL and a little bit of MS SQL.
Now, I want to parse some XML with PHP/USD exchange rate and store it in the database.
The simplest way one could think of would be, perhaps this:
$XMLContent=file("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=PHP");
foreach($XMLContent as $line){
$a=&strip_tags($line);
if (is_numeric($a))
{
// output the exchange rate
echo $a;
// THen I would probably go like this:
mssql_query('update table set xchange_rate='.(float)floatval($a));
// break cycle once found;
break;
}
}
That would perfectly do… if it didn’t take 0.8 seconds to run this script, due to external XML GET request.
So I suppose I should use Windows Scheduler, and make a task to run, let’s say every hour to update the records. Now the question is, I’ve no idea what script I would use. I mean, I can’t just simply run browser with a PHP script – that would be rediculous.
So, what would be the easiest way to make a script/ application to run it outside PHP, without a need to actually open a browser.
Thanks!
EDIT
Good point, right now I’m testing it on Win7, but later it is going to be implemented on Windows Server (2008?).
php has a binary executable interpretor too. On win, its called php.exe
http://php.net/manual/en/features.commandline.php
get it working first from a shell prompt, then make a scheduled task for it.
keep in mind, it is not the same php as you get when running a script through a webserver. Some settings are different, and the version may be different, and may use a different php.ini file(and so may have different extensions loaded).
consider using absolute file paths to start until you get things working.