Wednesday, 9 July 2014

The easy way to deal with dates in PHP

One of the good things that PHP versions 5.1 and above come with is the utility-


 date_default_timezone_set('timezone');

What it means is that whenever you will use the date() function, it will take as reference the "timezone" you specified.

For a list of timezones , click here.

Once this is done, call date() with the necessary formatting parameters, for example, the format accepted by MySQL i.e, yyyy-mm-dd .You get it by,
date('Y-m-d')


If you want to know what that means,click here .

With this procedure you are ready to use dates easily !!

Sunday, 25 May 2014

PDO -> The PHP Database Object

The PDO represents a connection between PHP and the Database Server.

Given the word object  in the title, we know that to use PDO, we need to instantiate it first.

From the PHP manual , I got :

public PDO::__construct ( string $dsn [, string $username [, string $password [, array $options ]]] )

or you can use

$pdo = new PDO(string $dsn [, string $username [, string $password [, array $options ]]) ;

The PHP manual says that DSN  (Data Source Name) contains the information required to connect to a database.

In general, a DSN consists of the PDO driver name, followed by a colon, followed by the PDO driver-specific connection syntax

I use mysql , so in my case, it will be 

"mysql:host=$databasehost;dbname=$databasename"
 
The username and password are clear.
 
Options :A key=>value array of driver-specific connection options.
       Ref :https://php.net/manual/en/ref.pdo-mysql.php

Friday, 25 April 2014

Shortcuts, Shortcuts Everywhere


In this post , I shall tell how to create a shortcut for Full Shutdown in Windows 8 and a shortcut to change proxy server quickly.


First, the Full Shutdown:

1. Right Click on Desktop and create a new shortcut.
2. Type the location of the item as shutdown.exe -s  (just like that) .
3. Give it an appropriate name.
           Done!!!

Second, the Proxy

1.Right Click on Desktop and create a new shortcut.
2. Type the location of the item as control Inetcpl.cpl,Connections,4  
3. Give it a name.
         Done!!!


The above 2 shortcuts will definitely save (if not much) your daily time.

Friday, 14 March 2014

Github Newbie or unable to operate Github for Windows? This might be for you.

I started using GitHub almost a month back. Initially, I used to create an online repository(repo in short) and create files there only. But How long could it go??

   So, I installed GitHub for Windows . The website boasts of it as "The easiest way to use GitHub on Windows" , this is indeed true. But Proxy users (like me :P) ,you might face some difficulty in the beginning,you might not be able to clone or push  your repositories from desktop. I had a similar problem and I contacted Steve Ward ,a GitHubber  and thanks to him, I can use GitHub even while using a proxy.Read on to find how you too can solve your problem.

  1. First of all, if this blog was not there, you would use this link to communicate your problem. But if you have the same problem I had , why go on to repeat the same task. Read the points below.
  2. My log file read :
GitHub.IO.ProcessException: Cloning into 'ERP'...
fatal: unable to access 'https://github.com/Acyut123/ERP.git/': Failed connect to github.com:443; No error

If you are behind a proxy or a firewall, Port 443 is blocked and this article might help you in order to open certain ports.


 If you didn't get that, no need to worry.(Note that GitHub doesn't officially support runnint the application behind a proxy ,for the release i am using.)

3.Open Git Shell and type in the following:

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

Replace `proxyuser` with your proxy username and `proxypwd` with your proxy password. Also, `proxy.server.com:8080` needs to point to the URL of your proxy server.

 I too followed the same and voila!!, immediately all the functions of GitHub became accessible from Windows.

Thank you GitHub for the awesome user service !!!

Edit

You might temporarily not require a proxy server for connecting to the internet, the commmands mentioned above will , in most cases prevent you to connect GitHub for windows to connect to the server.
Run the following command:
git config --global --unset http.proxy

and your network settings will be restored to the normal!!