Friday, December 03, 2010

BarCamp Apache Sydney 2010

Anyone interesting in BarCamps, The Apache BarCamp Sydney 2010 will be running at University of Sydney on 11th December 2010. The event is free and open for public. Details are available at http://barcamp.org/BarCampApacheSydney
See you there!

Thursday, July 29, 2010

Seventeen pages of success!

Anyone who is interested in building an identity on “the internet” as a business, person, product, community etc; no matter what, having a web page hosted on a web server wont do anything. I think almost everyone interested in internet would know this already. But the point is how? How you make your web site recognize in the internet? Answer is SEO, The magic called Search Engine Optimization. Why? Because anyone who’s looking for something in the internet will first go to a search engine like Google, Yahoo or Bing etc; then they will search for it, search engine will provide them with some results related to the search term based on the data available with them. Then the person looking for this information will use these results to get what they want. Means, they will find your web site if it is in the search results.

So if your web site to be in the search results, search engine should know about your web site. Search engines to know about your web site, your web site should be search engine optimized. How do you make your web site search engine friendly or SEO, I think I found a good way to start with. A small e-book explains a lot about SEO and how you do it. Click here and just have a look. I’m sure you will find this very useful.

Saturday, June 26, 2010

Microsoft SQL Server 2008 R2 RTM – Express is FREE!

Microsoft®  has released their free version of Microsoft SQL Server® 2008 R2 which is called  Microsoft® SQL Server® 2008 R2 RTM – Express. Microsoft®  says  

“It  is a powerful and reliable data management system that delivers a rich set of features, data protection, and performance for embedded applications, lightweight Web Sites and applications, and local data stores. Designed for easy deployment and rapid prototyping, this download includes support for Sysprep, Microsoft's System Preparation Utility for Microsoft Windows operating system deployment.”

I liked that part it says “lightweight Web Sites and applications”, so thought of downloading it which is with Management Tools since  it is also “FREE”. May be you can give it a try as well, click here to visit the download page.

Friday, June 25, 2010

Add styling to a Zend Framework based web application

Ordinary <link> tag won’t help you to add style sheets to a view script of a MVC application which uses  Zend Framework. This is because URL doesn’t direct to the actual root directory. But with help of a view helper, called baseUrl() it'll be easy to solve this problem.
Add following 3 lines of code to the <head>; section of your .phtml (view) script. Remember, in this case your CSS files should be in yoursite/public/css

echo $this->headMeta(); 
<head>
   echo $this->headMeta();
   echo $this->headTitle();
   echo $this->headLink()->prependStylesheet($this->baseUrl().'/css
        /mystyle.css');
<head>

Tuesday, April 06, 2010

PHP5 DB Connection Class with MYSQLi using Singleton!

Thought it would be a good idea to share my database connection class with you all, which I use in my apps. I have implemented this class in Singleton Design Pattern.
Use of this class will help you to manage the database connection of your PHP5 application, and will avoiding you and/or your programmers creating more and more DB connection instances, that will make your code more complicated and disorganized.

As a result of using Singleton Design Pattern, no one will be able to create more than one instance of the class. So whenever anyone tries  to create an object of this class, they will either get a new object when it is the first time you are creating an object of this class, else you will always get a DB Connection instance which has already begin created.

I have made this class little bit simple to help everyone could understand it and to use when ever you need it.

Here is the code,
 /*PHP5 MYSQLi DB Connection Class implementing Singleton Design Pattern
 * 
 * Author  : Thanura Siribaddana
 * Date    : 05-APR-2010
 * Web Site: www.thanura.com
 * 
 *  Usage:
 *   $db = DBAccess::getConnection();
 *   $query = "select * from TABLE";
 *   $result=$db->selectQuery($query);
 */
error_reporting(E_NOTICE);

class DBAccess{

 const DB_SERVER="localhost"; 
 const DB_USER="root";
 const DB_PASS="pass";
 const DB_NAME="dbname";
 
 private $_connection;
 private static $_dbinstance;

/* Made the constructor private, 
* to ensures that the class can only be instantiated 
* from within itself.
*/
 private function __construct(){
  try{
   $this->_connection= new mysqli(self::DB_SERVER,
                                     self::DB_USER,
                                     self::DB_PASS,
                                     self::DB_NAME);
   if ($this->_connection->connect_error){
       throw new Exception("Could not connect to Database.");
   }
  }catch(Exception $err){
   echo $err->getMessage();
   die();
  }
  
 }
 public static function getConnection(){
  if (is_null(self::$_dbinstance)){
   self::$_dbinstance= new DBAccess();
  }
  return self::$_dbinstance;
 }
 /* Execute a SQL query and returns the results*/
 public function selectQuery($query){
  $rs=$this->_connection->query($query);
  return $rs; 
 }
}

All comments welcome!! For fine-tuning... For better ideas... any thing...