Migration from MySQL to MSSQL our solutions – Continued

In the previous post, I had specified that a code analysis would be presented later on, which is happening now. Though I am not permitted to abstract the whole database abstraction, which would otherwise divulge the core business logic of the system too, I do expect that the following would be enough to guide a MySQL PHP developer to port his application to MSSQL 2005. Mostly the compatablities are maintained. But for the database design, we had to let away some of the wonderful features from MySQL.

We started by a code auditing and reworked the system such that we did not use any group_concat through out the system. Also all timestamp and datetime fields were changed to varchar(19) since we were already feeding those fields with the php function date’s return value or ‘now()’. But there was quite a handful of areas where we were using STR_TO_DATE and with different formats. So this had to be handled in its own way. And it is here we started our regular expression war path.
Continue reading “Migration from MySQL to MSSQL our solutions – Continued”

Porting application from MySQL to MSSQL

At first I thought it should be a challenge, though I did not expect it to be too tough, since we were already using a custom db wrapper. Well it turned out to be well too heavy a nightmare. And there was situations where I even considered retiring from life. I pity those who are paying thousands of hard earned money to buy such filthy crap.
Continue reading “Porting application from MySQL to MSSQL”

Convert MySQL Database to SQLite3 Database

For a cd based time limited working copy, of one of our products, I decided to port our mysql application to sqlite3. Since we had about 70 tables, and all with optimized indexes, and about 24 user defined function 3 triggers and 12 procedures, normally anyone would have thought of simply getting along with the mysql system itself. But I wanted to face the challenge. Thanks to Rob Cameron for the shell script published on his blog RidingTheClutch, Convert a MySQL database to a SQLite3 database, which sparked my thoughts.
Continue reading “Convert MySQL Database to SQLite3 Database”

Automatic image sizing with static delivery – WordPress Enhancement

Recently I got fed up trying to convince the operators of a client, for whom we had implemented a wordpress site. The operators, even after we repeatedly asked to upload only relevant sizes for certian positions, were trying to make one size fit for all. Hell, places where thumbnails of 1 to 2K would suffice, were being used up by 30K images, resized by our theme constraints. We were running wordpress on lighttpd.
Continue reading “Automatic image sizing with static delivery – WordPress Enhancement”

Short PHP twitter-counter

While strolling around I found some bits and pieces which I put together to get a short twitter counter in php.

<?php
ob_start
();
 
$json file_get_contents("https://twitter.com/statuses/user_timeline/php_trivandrum.json?count=1");
$data json_decode($jsontrue);
ob_get_clean();
 
echo 
$data[0]['user']['followers_count']; 
?>

Nothing more to write now..

MySQL FileSystem – A PHP Implementaion

After reading Using MySQL as a filesystem, by Ben Martin @ linux.com, I had been pondering over the idea for a long time. And a couple of sleepless nights, the base for phpmyfs, a mysql file storage engine using php at the front end is almost ready.  This is not yet production ready, though the image, or media management part is upto my expectations. Continue reading “MySQL FileSystem – A PHP Implementaion”

Paged Navigation – My own way

Recently while working for a wordpress plugin, though there are a lot of solutions for this, I could not find the exact thing which I needed, and thought about writing one of my own. Just writing it and using in the current project would be a waste, so thought I would slap it on here. It would help me in the long run.. Continue reading “Paged Navigation – My own way”

Fun digging into WordPress XML RPC

Once we achieved 20K visits per day at asianetindia.com (maintained by Saturn SPL), we planned to hammer in and our target was 30k in three months. We have achived that view the stats. For this twitter and blog helped a lot. We had added auto blogging, and wordtwit both to the existing asianetindia.com. It means each post when published will be tweeted, as well as a post to blog, which contains the excerpt with a back link to the original.

We wanted to get maximum links back into the blog also, and thought that a track back would be the best method and choose that against auto commenting systems. And a full time tester was doing linking related news and posts from other sites to our blog posts. It started to turn tiring when thought of the volume that was getting posted in a day. At this point, we at saturn started to think of automating the linking drive. The out come is autolinker, which is run using the random cron.
Continue reading “Fun digging into WordPress XML RPC”

Binary tree in MySQL for MLM

Recently for a student, I was asked to explain the design considerations of a Binary Tree which was to be used in an MLM solution. About 10 years back it was a nightmare, and in my career, I was lucky to get that privilage for more than a dozen times with varying schemes and structures. But now with MySQL having procedures, and functions, the tree design and related functions were a breze. Reproducing it here for future reference. This is in no way a complete solution, but just bits and pieces which may even be discarded as crap.

CREATE TABLE  `binTree` (
  `nodeid` int(10) unsigned NOT NULL auto_increment,
  `lnode` int(10) unsigned NOT NULL default '0',
  `rnode` int(10) unsigned NOT NULL default '0',
  `pnode` int(10) unsigned NOT NULL default '0',
  `pside` enum('l','r') NOT NULL default 'l',
  `tLevel` int(10) unsigned NOT NULL default '1',
  PRIMARY KEY  (`nodeid`),
  KEY `parent` (`pnode`),
  KEY `treelevel` (`tLevel`),
  KEY `lside` (`lnode`),
  KEY `rside` (`rnode`)
) ENGINE=MyISAM;

The above is the basic structure of the tree table, and some complementary functions and procedures are accompanied to make the usage simple, otherwise would be a herculian task for the developer to do the same.
Continue reading “Binary tree in MySQL for MLM”

Threading PHP scripts using OS facilities

Recently while developing systems which consumes webservices, after a lot of optimizations were put into our code, we resorted to do some sort of benchmarking. From the begenning itself, we had proper loggers which were logging the activities to database tables, and verbose text files. For benchmarking of the systems we use xdebug, and our Open PHP Myprofiler. The code coverage analysis by xdebug, as well as cache grind showed our bottleneck was our webservice provider. While checking out, we also found that we could reduce the waiting time for webservices by requesting smaller data set from the webservice.
Continue reading “Threading PHP scripts using OS facilities”