Wednesday, 22. March 2006, 10:51:23
coding, web, php, pm
...
Ok, so we're off with the portal, but at launch moment it didn't have PMs (personal messeges) feature. So my colegue helped me and made an awsome PM implementation (it's still under dev, though).
Of course we could have made it with IMAP back-end, but because of our cut on hosting and servers we're doing it SQL back-ended.
So normally one would do two tables (for inbox and outbox) and stuff one message into both tables. But my colegue came up with very brilliant and unique idea! Make three tables (read on...):
- One for all the messages (the 'container');
- One for INBOX (with message ids from first table);
- One for OUTBOX (with message ids from first table);
The first table with all the messages holds message id, text, sender, time, etc. AND additional field which states where message should be shown (or for a user sight - deleted/kept). If message is indicated as hidden (read: deleted) in both (inbox and outbox) it is deleted from 'container' as well. But to keep our server load as low as possible - there's cron'ed script for deleting all 'hidden' messages at midnight as well with other needless data (users that deleted their account, etc.).
Isn't that awsome?!
Saturday, 25. February 2006, 14:58:39
tips, errors
04:54 <MaR> all cool programmers have
error_reporting(($config['debug'] == TRUE) ? E_ALL : 0);
Or even cooler programmers (like my colegue), write their own error handlers ,)P~
Friday, 24. February 2006, 13:02:07
php, coding, tips
For long time i've been messing around with $_POST, $_GET, $_SESSION and $_COOKIES auto-global arrays, though typing $_POST['my_variable_from_form'] all the time (especially in encapsed or concatenated strings) isn't the biggest pleasure.
So i thought of a solution. I know that i've invented bycicle:
<?php
...
foreach ( $_POST as $key => $value ) {
${$key} = $value;
/**
* do any additional juggling with $value
* like cleaning from unneeded tags, adding slashes
* or anything else you might think of
*/
}
...
?>
Now i've been listing php manual after some time and found a function that does all the job for me and is even much more flexible!
<?php
...
import_request_variables('p');
...
?>
More on this on the web:
http://lt.php.net/manual/en/function.import-request-variables.php
Wednesday, 22. February 2006, 07:59:38
mysql, sql, php, database
...
Just remembered one thing: if you have home-made-hosting "company" and you provide MySQL databases as data storage server - don't use underscores (_) in databases' names. When you grant someone all priviledges on one db named user_db, then user can create even more databases, like:
- user0db;
- user1db;
- and so on...
I had that problem in my ex-work (Vilnius University IT Center). Thank God, i wasn't responsible for database administration (yet) .)
It's much better to gain such experience at 127.0.0.1 if u know what i mean .)