Jump to content

Who's Online script, run faster and more effectively in MySQL or SQLite?


MasterACE14

Recommended Posts

hey guys,

 

I started learning SQLite a few days ago, and can really see the advantages of the flat file database...

 

Basically, I currently have a script I use to see how many people are "Currently Online" on my website. It uses MySQL. I am wondering if it would be better(speed and server load wise, not that it would take much server load  :P)  if I used SQLite instead?

 

If so, would the same "MySQL CLAUSES" such as DISTINCT etc... are able to work in SQLite? as I know the WHERE clause works, im just not sure about some of the others.

 

here's my current script:

<?php

function active_sessions() {

/**
*
* TG WHO'S ONLINE
* Copyright 2005 - 2006 (c) TOXIC GOBLIN
* http://www.toxicgoblin.com
* 
*/

//Optional Database Connection Information
//**Uncomment the following 2 lines and edit the values if you do not already have an active database connection**
//

//Fetch Time
$timestamp = time();
$timeout = $timestamp - 900;

//Insert User
$insert = mysql_query("INSERT INTO cf_whos_online (timestamp, ip, file) VALUES('$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."')") or die("Error in who's online insert query!");
//Delete Users
$delete = mysql_query("DELETE FROM cf_whos_online WHERE timestamp<$timeout") or die("Error in who's online delete query!");
//Fetch Users Online
$result = mysql_query("SELECT DISTINCT ip FROM cf_whos_online") or die("Error in who's online result query!");
$users = mysql_num_rows($result);

//Show Who's Online
if($users == 1) {
print("Online Now: $users");
} else {
print("Online Now: $users");
}

};

?>

 

any help is greatly appreciated as always  :)

 

Regards ACE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.