acook Posted June 26, 2007 Share Posted June 26, 2007 Would it be possible to have a PHP script that would query one DB (Sybase) and dump the results into another DB (mySQL)? I've already got the query written and as it is right now, it just outputs the results by using: echo"whatever results"; Is it fairly simple to take those same results and drop them into the new DB? Also, is there a way to have this happen every 5 minutes? I'm assuming I'd have to put a refresh script (like javascript) somewhere on the page as the script wouldn't run unless it was invoked. Is that right? Thanks!! Link to comment https://forums.phpfreaks.com/topic/57308-using-php-to-query-a-db-and-dump-into-another/ Share on other sites More sharing options...
Wildbug Posted June 26, 2007 Share Posted June 26, 2007 Yes, it's possible; just use the functions as you would in any other application. Query one database, assemble a valid query for the other database, and execute it. No, this program won't run by itself unless you set up a crontab entry or your own little daemon. Or set it running in the background and put a sleep function in an infinite loop. Link to comment https://forums.phpfreaks.com/topic/57308-using-php-to-query-a-db-and-dump-into-another/#findComment-283317 Share on other sites More sharing options...
acook Posted June 26, 2007 Author Share Posted June 26, 2007 Yes, it's possible; just use the functions as you would in any other application. Query one database, assemble a valid query for the other database, and execute it. I guess the problem I'm running into is the dumping of the results into another DB. I've already got all of my results in an array. Do I just create another query like: INSERT INTO blah $value1 Or something similar to that? Link to comment https://forums.phpfreaks.com/topic/57308-using-php-to-query-a-db-and-dump-into-another/#findComment-283407 Share on other sites More sharing options...
Wildbug Posted June 27, 2007 Share Posted June 27, 2007 Sure, you can do that. You don't have to put it in an array; you can assemble the query directly. // Connect to dbs, query Sybase. // Read data and assemble query: $mysql_insert_query = 'INSERT INTO mytable VALUES '; while ($row = sybase_fetch_row($result)) $mysql_insert_query(vsprintf("('%s','%s','%s','%s')", $row)); // Execute query: mysql_query($mysql_insert_query); Link to comment https://forums.phpfreaks.com/topic/57308-using-php-to-query-a-db-and-dump-into-another/#findComment-284016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.