Pages

Monday, May 14, 2012

Executing where Condition in phpcasa

When I start learning about Cassandra, first thing in my mind is how to execute traditional where condition. It may be very simple but it took lot of my effort to figure out.

A very basic example is


<?php
require_once('phpcassa-0.8.a.2/connection.php');
require_once('phpcassa-0.8.a.2/columnfamily.php');

$pool = new ConnectionPool('Keyspace1', array('localhost'));

$column_family = new ColumnFamily($pool, 'users');

$index_exp = CassandraUtil::create_index_expression('birth_date',1975);
$index_clause = CassandraUtil::create_index_clause(array($index_exp));
$rows = $column_family->get_indexed_slices($index_clause);

foreach($rows as $key => $columns) {
  print($columns['full_name']);
}

If this code works for you, you are lucky. If not then, you should learn what is Secondary indexes in cassandra. please go What’s new in Cassandra 0.7: Secondary indexes

Friday, May 11, 2012

Decide Drupal or PHP ?

Both technology, has it's own potential, in their area. First I will brief about the both technology, and what is their area.

Drupal: 

This is one of the strongest tool built for php developer. It comes with it's own code base(file & folders) and database. Not only that there are 15,993 third party modules(Free), 1,374 Themes(UI). So basically, Drupal is built with all the generic features which almost 70% web applications requires. Features like user accounts, roles, permissions, Admin CRUD, Generic report.

Pros 

  1. Development becomes very fast, since instead of writing code developer assembles drupal modules. 
  2. Lot of features are already developed, it has a very active community, available for support. 
  3. It is CMS cum Framework, so when require we can write our own custom module also. 

Cons 

  1. It has its certain core area (codebase & DB), that is not changeable. 
  2. Even though, one can develop custom modules, but it has to follow drupal standard, which ultimately make a boundary for developer. 

When to use drupal 

  1. When we know we are going to build a generic web applications. Where things are straight forward. 
  2. Client requirement are not stiff. Client is ready to accept our suggestions. 
  3. When we need to make process fast. 

When not use drupal

  1. When your requirement may break the drupal core system. 
  2. When client is more cautious about the quality, rather than time or budget 
  3. When you don't have right resource 

PHP

PHP, is the Father of Drupal, and Father is always bigger than child :). What ever we can do with drupal, i.e. also available here, with unlimited freedom. This is pretty similar to command line of any operating system(like linux) and it's GUI alternative. 

Pros

  1. Here since you start from scratch, you can plan your core DB & code base. From here your freedom starts. 
  2. PHP also has its own very robust, mature community. these people don't write their contribution in a standard module. but they talk and write in some CMS or framework in which they are good. So you get support but nothing like plug n play module. 
  3. As you are free to work in PHP, at the same time if you can google, and find(not guaranteed) something already written, and same(if not exactly then 80% same) as your project would be. 
  4. Resources are easily available. 

Cons: 

  • Compare to drupal, only thing which is lacking here is, some time for small thing. it takes too much time. 

When to go with PHP 

  1. When your application is using multiple technology. 
  2. Client requirement contains lot of exclusive things. Like some client want to set a new trend with their application. Some time they want to beat Facebook, twitter and even google also :). 
  3. When Your client use words, like pixel perfect, it should be in professional way or It's a common web standard, etc. 

When to not go with PHP 

  1. When Client asks suggestion from you, and you know you can mould in your way.
  2. In your application, there is nothing like you invent something from zero.

Other References: