Hi Folk
I am running a site (A) that has a US mirror (B). This means that all
the data from A is copied daily to B.
On the site, I keep some statistics of the pages people visit, tracking
them with a session and noting their searches, etc... for statistical
purposes.
The problem I have is that if someone visits site B then at the end of
the day, their statistical data is going to be overriden by the update
from A.
To counter this, I envisaged a system where the stats dont just run an
sql statement to update my MySql database, but instead, the statements
"include" a URL on A that runs the statement.
For example:
---
Old procedure:
function add_user_page() {
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES (1,2);");
}
---
New procedure:
function add_user_page() {
if(site B) {
include_once("h ttp://A.com/runstats.php?fu nction=add_user _pageB&table=US ER&V1=8&V2=9") ;
}
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES (8,9);");
}
---
I would then create a file runstats.php with the following code:
<?php
call_user_funct ion($_GET["function"], $_GET);
function add_user_pageB ($name, $v1, $v2) {
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES
('.$v1.','.$v2. ');");
}
?>
This is obviously super simplified and not tested.
The questions I have are
1. is this a good method?
2. can I / should I use "include_on ce" or is there a better way to run
(call) the runstats.php page?
NOTE: my ISP does not allow me to connect directly from B to the
database on A.
Thanks in advance for any comments
Nicolaas
I am running a site (A) that has a US mirror (B). This means that all
the data from A is copied daily to B.
On the site, I keep some statistics of the pages people visit, tracking
them with a session and noting their searches, etc... for statistical
purposes.
The problem I have is that if someone visits site B then at the end of
the day, their statistical data is going to be overriden by the update
from A.
To counter this, I envisaged a system where the stats dont just run an
sql statement to update my MySql database, but instead, the statements
"include" a URL on A that runs the statement.
For example:
---
Old procedure:
function add_user_page() {
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES (1,2);");
}
---
New procedure:
function add_user_page() {
if(site B) {
include_once("h ttp://A.com/runstats.php?fu nction=add_user _pageB&table=US ER&V1=8&V2=9") ;
}
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES (8,9);");
}
---
I would then create a file runstats.php with the following code:
<?php
call_user_funct ion($_GET["function"], $_GET);
function add_user_pageB ($name, $v1, $v2) {
mysql_query("IN SERT INTO USER (PAGEID, USERID) VALUES
('.$v1.','.$v2. ');");
}
?>
This is obviously super simplified and not tested.
The questions I have are
1. is this a good method?
2. can I / should I use "include_on ce" or is there a better way to run
(call) the runstats.php page?
NOTE: my ISP does not allow me to connect directly from B to the
database on A.
Thanks in advance for any comments
Nicolaas
Comment