Category: SQLite

converting standard wordpress into a SQLite powered multi user blogging platform

wordpress is one of the very popular blogging platforms which is not only free but also released as a open source project. officially wordpress runs only on mysql. so if you want to run it with SQLite, you will not find any official support for that. but fortunately justin addie has written an excellent plugin (pdo for wordpress) which will work as an adapter just between the wordpress DAL and mysql. this plugin hooks all the SQL queries which are sent to execute on mysql by wordpress, convert those into PDO compatible statements and then execute them. currently PDO for WordPress is written to work smoothly with mysql and sqlite.

on the other hand, WPMU (wordpress mu or multi-user) is another version of wordpress which uses the core wp with some modifications and convert any single user wordpress blog into a multi user blogging platform. in this blog post i will show you how you can convert a general installation of wordpress into multi user blogging platform (like WPMU, but fully featured) and take advantage of SQLite 🙂 – so let the fun begin.

step 1: check if your domain support wildcard A record. if so, then create a “*” A record and point it to your server. if it works, now you can point http://.. to your server 🙂 – that is very much required. alo please check that in your webserver it has “pdo” and “pdo_sqlite” php extensions enabled. you can check that using phpinfo(); – needless to say, you need PHP5

step 2: install wordpress

step 3: install pdo for wordpress
download the pdo_for_wordpress plugin. inside it you will find one file named “db.php” and a folder named “pdo”.
put the db.php inside “wp-content” directory
now put the “pdo” folder inside “wp-content” directory

open wp-config.php
find the following line
[sourcecode lang=”php”]
define(‘DB_COLLATE’, ”);
[/sourcecode]

add the following line just below that line
[sourcecode lang=”php”]
define(‘DB_TYPE’, ‘sqlite’);
[/sourcecode]

step 4: create a directory named “userdb” anywhere in your server, make sure to give it write access. in this example we’ve created one as /opt/userdb – DONT FORGET TO ASSIGN WRITE PERMISSION to this “userdb” directory.

step 5: now we will be modifying that “db.php” which we had copied into “wp-content” folder.

find the line in db.php where it says
[sourcecode lang=”php”]
define (‘FQDBDIR’, ABSPATH .’/wp-content/database/’);
define (‘FQDB’, FQDBDIR .’MyBlog.sqlite’);
[/sourcecode]

now change those lines as below
[sourcecode lang=”php”]
define (‘FQDBDIR’, ‘/opt/userdb/’);
define (‘FQDB’, FQDBDIR ."{$_SERVER[‘SERVER_NAME’]}.sqlite");
[/sourcecode]

and tada – you are done. now point your browser to any subdomain under your domain and it will comeup with registration page. register some blog and check it out 🙂 (at the bottom of this post you can find the link of a live demo)

now you can extract some themes in the wp-content/themes folder or some plug-ins into wp-content/plugins folder. all users will be able to choose only from those pre installed themes and plugins, and everyones data and configuration will remain separate from others, as everyone is running from their own database. set only “read” access to “wp-content/themes” and “wp-content/plugins” folders to avoid any security loophole.

happy blogging.

[note – i’ve checked it against latest wordpress 2.8.4 and it runs okay]

To check out a live example of a running wordpress 2.8.4 on SQLite – click on http://anything.twistats.com/wp/ – and to create your own – just go to this url http://<any_subdomain>.twistats.com/wp and register your one :). You can select from six pre installed themes too 🙂

Prelude to foundation: Its time to go for a better PHP Framework

I remember those old days when I had to write everything by myself. I wrote huge libraries to work with MySQL. Then I learned PostgreSQL and SQLite but didn’t rewrote my old library to work with those, I was running short of time. So I forsake the opportunity to write a db library which works with them. What I did was plain code relevant to database specific portions. Oh ya, that was a long time ago.

Soon after that I came to know adoDB which made my dream come true. I was so much happy getting my all db specific works done in a much more smarter way. I get rid of database portability issues. I was very happy that time.

I learned smarty soon after I realize that my codes are getting ugly with all the inline HTMLs and PHPs. Nothing could be smarter than separating the presentation logic from the business layer. I am a big smarty fan since that time. It saves my sleep for many nights.

But again I am recurrently suffering from maintainability issues. I was not surprised to find that my code is becoming huge unmanageable giant and it takes huge time for refactoring the application. I was very sad those days. Oh what a disaster that was.

When working with my team members located remote places, I fall into a deep shit. How can we manage and track the changes done by us? Even I was getting strange code in my routine which I bet was not written by me!! It was a terrific job (more…)

Just PHP will give you nothing… unless you upgrade yourself

I have been working with PHP for more than 3yrs (I believe still I am beginner in this category) – I was present in several interview board. Which things disappointed me most is the “lack of eagerness” to learn what comes new. Sometime developers thinks that learning Only PHP will help them to get lucrative jobs!! OMG

Specially in BD most of the time PHP developers plays multiple roles in the companies, they are developer, they are template designers, they are HTML coders, they are DBA, they are PMs….what the heck. Only few companies have different people for these roles.

How far you can go just learning PHP (RAW code, in ancient style, that means PHP+HTML together, yak!!)? You have to have knowledge in CSS, JS, Frameworks, Multiple DBS

When it comes the question of CSS, you should maintain a list of websites where from you can get updates. Dont learn the CSS from book, but goto websites and see what is happening… If you are still using Tables to design (more…)

WordPress4SQLite – alpha one

The project finally see some light. It comes to a prematured state where it is working smoothely, but with lack of some features. I have to go thru every piece of code where SQL statements are present and I make them SQLite compatible. The project is not finished, Category and Image upload is not working properly but I will complete them next week. I have been suddenly bz in another official project which I have to complete within next 5 days, so I may not be able to contribute before next week. But I am extremely confident that I can solve those problems.

You can download this prematured version of WordPress4SQLite from the following link and just after modifying the config file as usually, you can proceed.

Please note that error reporting has been turned off just to save you from some annoyances :D. If want to turn error reporting on, open wp-includes/wp-db.php and remove the error_reporting() function.

There is a sample config.php file present already. You can modify it to kickstart using WordPress4SQLite. Please use absolute path for database file.

Download From Here : WordPress4SQLite

You can see a running version of WordPress4SQLite here

WordPress SQLite – Update One

1. Installer is Finished
2. WordPress DB core conversion finished

Now I am stuck with Role Management and I will finish it hopefully within a day. Last night a funny thing happened. In wordpress installer they check whether a table has been successfully created by invoking “SHOW Tables” command which is not compliant with SQLite. So I start searching how to get information about database scheme. After searching for a while, I finally went thru the code of phpsqliteadmin and found the solution.

Every SQLite database has a table called SQLITE_MASTER which remains hidden. So you can just execute the following command to get all the table names.

“SELECT name FROM SQLITE_MASTER where type=’table'”

Really Cool. !!! I am very much excited abt this project and I am sure – I will release it in friendly way. In WordPress SQLite edition you can use standard wordpress distribution (with modified db core) but you can just configure your config file and add the following line.

driver = ‘sqlite’

I just want to avoid all the hassle for the end user 🙂

Lets see!!