![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
New to the CF scene Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
If row exists then update if not add new row.
Hi,
I am trying to make a script which gets a list of Ports and IPs from a remote mysql DB. With each result from the DB it is used to ping the servers to generate the stats.. I first tried doing this and let it scan the servers all on one page. I found this was a very slow result.. about 5 minutes to scan around 20 servers. My other option now is to get a cron job every 10 minutes to launch a script which scans the servers and then adds the result into a DB. This is where i get stuck! I want this all to be dynamic so I dont have to add and remove ips when the customer changes his mind about his CS source port. What I want to do is: If row exists then update that record with the status of the server, if the row doesnt exists then make one. The eventual displaying and scanning is in theory quite easy but the MYSQL (is record there) is where I get lost.. wondering if there is a shortcut without me needed to do a sql statement to see if it exsists. How would i go round to do this? Last edited by ChrisOlver; 02-12-2005 at 07:19 PM.. |
|
|
|
|
|
PM User | #2 |
|
New Coder ![]() Join Date: Feb 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
mysql_num_rows
so lets say your row with ip 111.111.111.111 exists, just make a query like PHP Code:
|
|
|
|
|
|
PM User | #3 |
|
Regular Coder ![]() Join Date: Sep 2002
Location: British Columbia
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
This is exactly what the REPLACE command is for http://dev.mysql.com/doc/mysql/en/replace.html
__________________
http://skyscraperpage.com/ |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|