Posted in Uncategorized

Downgrade PHP7 to PHP 5.6


Then I had to downgrade to PHP 5.6
There are 2 ways to do that. Remove PHP 7.0 completely & install PHP 5.6

sudo apt-get remove php7.0*
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php 5.6

Keep both PHP 7.0 & PHP 5.6, switch accordingly

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring  libapache2-mod-php5.6 libapache2-mod-php7.0

Now to use PHP7.0 use the following command

sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart

And to use PHP5.6 use the following

sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart

That’s it!

Posted in Database Doctrine, Uncategorized

ZF2, Doctrine & Oracle

To do: Setting up Doctrine to use Oracle
So, here we go.

  • I assume you have added Doctrine module, if not refer here
  • Next open your

    & add the configuration as follows

    return array(
        'doctrine' => array(
            'connection' => array(
                'orm_default' => array(
                    'driverClass' => 'Doctrine\DBAL\Driver\OCI8\Driver',
                    'params' => array(
                        'host'     => '',
                        'port'     => '1521',
                        'user'     => 'iamuser',
                        'password' => 'xxxx',
                        'dbname'   => 'mydb',
                        'driver'   => 'oci8',
                        'service'  => true,
  • Next, install libiao
    sudo apt-get install libaio1

    Then install the oci8 driver . You can dowload it from Oracle’s site

  • Now, enable it in php.ini. Open it
    sudo vi /etc/php5/apache2/php.ini

    & add the extension like
  • Don’t forget to restart apache
Posted in Database Doctrine


Doctrine ORM expects every table to be an Entity. But that is not easy , when dealing with complex query and which requires querying the result..
So, a hack to this problem is Resultsetmapping class, which allows you to write sql query and then map the result to Doctrine… Here is an example:

use Doctrine\ORM\Query\ResultSetMapping;
$query =   "select as id,q1.display_id as display_id,q1.product_id from
                        	(SELECT *
                        	FROM (
                        	SELECT id, display_id,active_flag,hash,product_id
                        	FROM test_case
                        	where  product_id=$productId and active_flag=0
                        	ORDER BY display_id DESC
                        	) a
                        	GROUP BY hash
                        	) AS q1
                        	(SELECT *
                        	FROM (SELECT id,display_id,active_flag,hash
                        	FROM test_case where product_id=$productId
                        	ORDER BY display_id DESC) b
                        	GROUP BY hash ) AS q2
    	$rsm = new ResultSetMapping();
    	$rsm->addEntityResult('Test\Entity\TestCase', 'TestCase');
    	$rsm->addFieldResult('TestCase', 'id', 'id');
    	$rsm->addFieldResult('TestCase', 'display_id', 'displayId');
    	$rsm->addFieldResult('TestCase', 'product_id', 'productId');
    	$query = $this->getEntityManager()->createNativeQuery($query, $rsm);
        $testCaseDrafts = $query->getResult();
Posted in programming unix

Users, Groups and Permissions on Linux

  1. Adding a user
    sudo adduser <username>
    e.g.: sudo adduser thabung
  2. Delete a User
    sudo deluser <username>
    sudo userdel thabung
  3. Changing the user password
    sudo passwd <username>
    sudo passwd thabung
  4. Adding a group
    sudo groupadd <groupName>
    sudo groupadd programmers
  5. Removing a group
    sudo groupdel <groupname>
    sudo groupdel programmers
  6. Group information
    sudo vi /etc/group
  7. List the groups which the user is in
    groups <username>
    groups thabung
  8. File permission
    Write : 4, Read : 2, Execute: 1
    So, 4+2 = 6, means file/folder has read& write permissions
    4+2+1 = 7, means read, write & execute permissions(full control)
    change the file permission of a folder
    sudo chmod -R (owner)(group)(public) <folderName>
    e.g. sudo chmod -R 775 music
    It means:
    The owner can Read + Write + Execute (4 + 2+ 1 = 7)
    Group members can Read + Write + Execute (4 + 2+ 1 = 7)
    Public can only Read + Execute (4 + 1 = 5), but cannot write/modifychange the permission of a file
    sudo chmod  (owner)(group)(public) <fileName>
    e.g. sudo chmod -R 775 music/animals.mp3
  9. Change the file/folder ownership
    sudo chown -R <username>:<groupname> <pathToFolder>
    e.g.sudo chown -R thabung:www-data /var/www/mysite