Friday February 10, 2012 @ 20:18:11 GMT+10    ( Weather:  n/a )
Home » Weblog Archives

Powered byD's Bloggie
Weblog » Archive » 2005 » December » Day 17
Browse by day ...
 11 December, 200521 December, 2005 

New design approach - 2:54 am
Coding , PHP , Site Issue , Site Updates , Standards  -  poster 

I'm updating my site again. I've been working on the core functions / classes. Yes, the CORE part... The major ones are like user authentication and database connection. I've unified all database access under one global variable, avoiding multiple DB connection objects created locally (class/function scope). The good thing about ? it saves memory and I can know how many SQL queries are made to construct a page. Scroll down to the very bottom and you can see how like "N queries made". Quite surprising though... some pages used like 35 SQL queries... o.O omg... gotna refine them later...

My current approach [ Hide ]
[ Highlight ] [ Text ]
-------site_management.php---------------
// The class of "everything", contains db connection
// and other authentication
class site_management
{
    var $DB_OBJECT;
    function site_management()
    {
        // Let's say MYSQL_DB is your class that contains
        // all functions to access/manipulate the database
        $this->DB_OBJECT = new MYSQL_DB();
    }
}
 
-------foo.php--------------------
// Some class that requires access to database
class foo
{
    // Internal database connection object
    var $_db_object;
 
    function foo()
    {
        // If global variable $SITE->DB_OBJECT exists, make reference
        // to it otherwise instantiate a new copy locally
        if (isset($GLOBALS['SITE']) && $GLOBALS['SITE']->DB_OBJECT)
            $this->_db_object =& $GLOBALS['SITE']->DB_OBJECT;
        else
            $this->_db_object = new MYSQL_DB();
    }
 
    function bar()
    {
        // You need to perform sql query here
        $this->_db_object->query($sql); // for example
        // ...
    }
}
 
------test.php-------------------
// The above two class is located in different files
// and below is also in a seperate script file
<?php
    $SITE = new site_management();
    $foo_obj = new foo();
    $foo_obj->bar();
?>


My old way [ Hide ]
[ Highlight ] [ Text ]
-------foo.php--------------------
// Some class that requires access to database
class foo
{
    // Internal database connection object
    var $_db_object;
 
    function foo()
    {
        // Instantiate a new copy locally
        $this->_db_object = new MYSQL_DB();
    }
}


Let me know what you think about this. You can also leave me a message here.

Read more about referencing global variable:
http://www.php.net/manual/en/language.references.whatdo.php
http://www.obdev.at/developers/articles/00002.html

In authentication part I removed ALL spaghetti-style-redirection when transfering a user through a login/logout. In short, no more hidden values inside <form> to track user, session is used instead. Clean code and it works! Hopefully things will work fine... even though I'm extremely carefully when touching the core part, because almost everything are built on top of it.

You should also have notice the "N visitor(s) online now" thing on the left navigation menu. Although most of the time there is only 1 visitor, me myself lol Talking about the navigation menu, I'm adding options to show/hide the menu with javascript. See that red button with a 'X' ? That's what I'm talking about.

Others updates are misc and minor updates in template/admin control panel.

Little grumbling... - 3:01 pm
Personal  -  poster 

This is my blog right ? I can do anything I like right ? So let me grumble a little...

Walao eh.. why this is hapenning on me leh... gai nia, why me become sandwich in between some trouble eh ?? you think me standing between very fun ah ? weather so hot now 36 degree making everybody zhao hui nia.. really **** .. kao... next time I surely don't care about this anymore... !@#$%^& let me close all eyes better than close only one eye..me no eye watch and care liao...

Last edited: Sun 2005-12-18 @ 02:01 , by DaRen 2 time(s)

RSS - 4:11 pm
Computing , Internet , Site Issue , Standards  -  poster 

Lately I'm interested in RSS and I'm considering to prioritize and make it the first thing on my todo list.

RSS

(Really Simple Syndication) A syndication format that was developed by Netscape in 1999 and became very popular for aggregating updates to blogs and the latest news from Web sites. RSS has also stood for "Rich Site Summary" and "RDF Site Summary."

RSS is a family of XML file formats and the information is delivered as an XML file called RSS feed, webfeed, RSS stream, or RSS channel.


Drop me a line if you know any good PHP RSS parser/reader/aggregator. I'm also interested in RSS feed generator in PHP. I wanna learn more about RSS feed and put up a feed on my site.

Some feed parsers that "looks" good among others:
  • Magpie RSS - packed with hell lots of features and functions, used by alot of RSS software
  • LastRSS - light weight RSS parser
  • Lilina News Aggregator - some sort of feeds on feeds, using Magpie library
  • Tiny Tiny RSS - not tiny at all, web based RSS reader works like desktop version. Using Magpie library

Feed generator/writer:
... haven't test them though..
 11 December, 200521 December, 2005 
$ view_blog.php 2009.09.17 18:16:41 $
Lost? | XML/HTML sitemap | Contact
38.107.179.242 , 19 queries , 0.0962s
Gzip enabled , CSS compressed , JS compressed
Copyright © 2005-2011 Darren's Outpost