MYSQL + PHP
I'm not too familiar with the limitations of Mysql. I've got it installed via xampp on my system, and am about to use a php for loop to create and populate a table with 9801 entries. Before I write the code and execute it, I want to check that this isn't a ridiculous idea akin to splitting a 700mb file into several million segments within a window folder. How many values can a mysql table hold on a gaming machine before it becomes inefficient?
Comments
If you want to serve the mysql all the time, though, you'll be taking a performance hit on your other applications, depending on how busy the mysql server is. I'd recommend just buying some shared hosting in this case. I use Dreamhost, and I'm pretty happy with them.
As for using PHP to populate the server, it might be better to just write an .sql file with INSERT statements, unless you need the php code to go out and get data to be put into the server or something.
Our development box at work is something like a 1.2ghz single-core celeron and it's very speedy w/ tables that are around a gig.
If you have 10,000 rows and things slow down, the problem won't be the hardware. :P
Also a general tip regarding data checking:
MySQL can almost always do it faster than PHP.
So if you're going to turn 3 phone number fields into 1 combied field w/ dashes between them, this is something to do on the MySQL side.
For this you want to create a seperate table that has these fields:
- messageid (primary key, autoincrementing)
- userid (foreign key)
- message (text to store the message)
- messagetimestamp (stores when the message was created)
You'll insert rows into this table whenever a message happens, then when you need to display them just get the last 5. Then you just loop through the array..
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$sSQL = "SELECT message FROM messages WHERE userid = '1' ORDER BY messagetimestamp DESC LIMIT 5";
$r = mysql_query($sSQL, $db);
if ($r && mysql_num_rows($r))
{
while($row = mysql_fetch_assoc($r))
{
$aMessages[] = $row['message'];
}
}
else if ($r && mysql_num_rows($r) === 0)
{
// No results returned from database, so do something else here
}
else
{
echo 'Error: '.mysql_error($r);
}<!--c2--></div><!--ec2-->
or something similar.
Having 1 text field w/ up to 5 messages stored inside of it, separated by a delimiter, is about the worst thing you could do in this situation.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if ($planetinfo['owner'] == $_SESSION['user']) {
// Separate functions I guess bro
}<!--c2--></div><!--ec2-->
my guess:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if owner of planet is same as currently logged in user{
do something
}<!--c2--></div><!--ec2-->
Whenever I do stuff like that I always put // TODO: whatever in the code. :P
My desk at work is also littered w/ post-its from various things.
Whenever I do stuff like that I always put // TODO: whatever in the code. <img src="style_emoticons/<#EMO_DIR#>/tounge.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tounge.gif" />
My desk at work is also littered w/ post-its from various things.<!--QuoteEnd--></div><!--QuoteEEnd-->
I usually use @todo inside of a longer /** */ comment so that both our documentation generator and my IDE pick them up and give me a nice list.
On an unrelated note, when I'm working with some of my php scripts I have gotten php to where it uses around 500 mb of ram ;p.