Re: talking to external MySQL servers
Re: talking to external MySQL servers
- Subject: Re: talking to external MySQL servers
- From: Rob Stott <email@hidden>
- Date: Thu, 14 Jun 2007 08:55:52 +0100
On 14 Jun 2007, at 07:14, Håvard Graudo wrote: It should preferably be free (or cheap), small and in the form of an OSAX, a faceless background app, or a command line app. Small enough to be embedded in a script bundle if necessary.
Hmmmm...
You could use PHP from the command line, couldn't you? Here's an extremely basic bit of PHP I use to return a list of user names from one of my mySQL databases (early days for me with both PHP and mySQL so experts will probably scream in horror at this - it does the job I want it to though!).
I save the following in a file called userlist.php
#!/bin/php <?php
$con = mysql_connect("myipddress","myusername","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); }
// choose the database to use mysql_select_db("mydatabasename", $con);
$theQueryResults=mysql_query("select * from users");
while($theRow = mysql_fetch_array($theQueryResults)) { echo $theRow['forename'] . " " . $theRow['surname'] . "\n"; } mysql_close($con);
?>
...and run it from the command line with;
php userlist.php
...like I said, there are probably more elegant solutions, but that does the job for me. Hope that's of some help and I look forward to others' suggestions.
Rob
Important: This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination or copying of the communication is strictly prohibited. If you have received this communication in error, please notify the writer immediately by telephone and return the original message via postal service to the writer's attention at the above address. Thank you.
Watt Gilchrist Limited. Albion Mills, Albion Road. Bradford, BD10 9TQ
Registered in England
873405
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden