Monday, November 28, 2011

Learn linux

If you want to learn linux and download some books on it visit Linux Tips

Linux OpenSUSE 12 Review

OpenSUSE 12 Review


Ubuntu Gadgets

I am using Ubuntu so I found several usefull gadgets for your desktop.


The clock, weather and the calendar are the most I use :)

Linux Mint 12 Review

If you are a Linux fan like me, here is a Linux Mint 12 Review


Wednesday, November 23, 2011

Database solutions for PHP

In this post I will explain the most popular and most used database engines capable of working with PHP.  They are many, and have different capabilities and architectures. Some of them are payable and expensive, some of them are open source. So depending on your needs you can use some of the great variety of database engines. No matter which one you use PHP has prebuilt drivers and PDO libraries for the all of them.

Here is a short list:
1. SQLite (open source)
2. MySQL (open source)
3. PostgreSQL (open source)
4. dbm-style databases (Oracle Berkeley DB)
5. Oracle Database (payable), Oracle XE (open source)
6. ODBC

1. SQLite

Although you might think that MySQL is most popular when working with PHP, you are quite wrong. The most popular db engine is SQLite. It is so popular because it is small, reliable and also embeded database engine. When you develop application that uses SQLite it is by default embeded inside the application that uses it, for example Firefox, Skype, mobile platforms like Symbian, iPhone etc. In the newest version of PHP SQLite is bundled with it so you don't have to install anything additional. It is fast and supports the SQL standard commands. It is simple because it is not structured like client-server and the code is open source so you can use it and modify it to your needs.

Some of the features of SQLite:

 - Dynamically typed: Given field can hold different types of data from one record to the next, much like a NoSQL database. This is very useful when working with PHP since it is loosely typed language. The drawback is that it is hard to maintain db integrity and it is not compatible with other db engines.

- Given database is stored in a single cross platform db file. So you can easily use the same db with other application that works with SQLite.

- It is easy to configure because there is no need of installation and no need to create users and add persmissions.

- You can call PHP commands from within an SQLite SQL query. So when working with some query you can call PHP function within the same query and it will surely work well.

MySQL is most known by PHP developers so I will jump right to 3.

3. PostgreSQL

PostgreSQL is also open source db engine much like MySQL. In fact the closest relative to MySQL is PostgreSQL. They both support the same capabilities and work at the same level of scalability. MySQL is known for its ease of use and great speed, while PostgreSQL is known as feature rich and reliable. But as the time passes both of them became powerful enough and surpassed their disabilities. You can access PostgreSQL with extension and also with PDO driver much like MySQL. So after this you can use both, as they are both good. It depends on your flavour which one to choose.

4. dbm-style databases (Oracle Berkeley DB)

 dbm-style database is an embeded type of db developed in 1970s. It is like SQLite but not nearly powerful. It stores files on the hard disk and it doesn't use SQL commands. But it can be very fast as records are taken with only a given key. This type of dbs aren't used very much today but the most popular of the existing is Oracle's Berkely DB.

5. Oracle Database and Oracle XE

Oracle is a company most well know by the database software systems that it develops. Oracle databases are used mainly in large organisations and companies that have a need of complex queries and store large amounts of data. Thus it is very expensive to use. So if you need small scale db engine for a low traffiic application than you should use the above given or Oracle's XE edition which is open source. For use with PHP you can use OCI8 extension or PDO driver.

6. ODBC

ODBC is not a database engine but it is an API interface for accessing and working with several db engines like MS Access, MS SQL server, and IBM's DB2 engine. MS Access and SQL Server are only available on Windows systems so this would be good solution if you work on Windows. As for DB2 there are AIX and, Unix, Linux and Mac as well as Windows.

Windows has preinstalled ODBC driver but there are open source drivers for other platforms like Linux, Unix and Mac OS X.

Ok so this would be all about PHP compliant db engines.

used literature from Beginning PHP 5.3 by Matt Doyle