Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.