Quote:
Originally Posted by SchurmanCQC
Using SQL and checking constantly (constantly querying!) is very inefficient and a bad idea overall.
I suggest using sockets.
http://php.net/manual/en/book.sockets.php
EDIT: Also, the preview has header warnings. It makes your code really look bad...
Another thing, I know the size of the code is small, but if you can organize things that are used in a lot of places into classes, things would be a lot more organised.
PHP код:
/*
bool SQLClass ( string conIP, string conUser, string conPass, string conDatabase )
This function initialises the SQL connection.
*/
class SQLClass {
function SQLClass($conIP, $conUser, $conPass, $conDatabase) {
...
return true;
}
}
|
I'm aware that querying a database isn't the optimal solution but this is just a prove of concept -- though this isn't that much slower than sockets especially if someone where to use MySQLi or ODBC with a persistent connection + with push (rather than poll which it uses at the moment) you would not experience any redundant queries. This is especially a good solution if your webserver has sockets disabled (which I understand many providers enforce) or if you don't want to use sockets. You're right it could have been done more efficient -- maybe I'll do that in an update (fixing the header stuff too).
As for the SQLClass -- it's not necessarily. There is no code duplication anywhere. Why would I add the complexity of OO when I just need a few lines of code.