August 25

Sorting Arrays of Arrays in PHP

phparray

This is a very common task for PHP programmers as data returned from database/SQL queries often appears in associative array format.

1. The Data

The following examples are based on the following data as an associative array. The data contains six records, each of which has a value for “firstname”, “lastname” and for “age”.

<?PHP $data = array( array("firstname" => "Maya", "lastname" => "Joshi", "age" => 35), array("firstname" => "Amar", "lastname" => "Mule", "age" => 33), array("firstname" => "Jatin", "lastname" => "bhore", "age" => 27), array("firstname" => "Pratika", "lastname" => "Wankhede", "age" => 7), array("firstname" => "Minal", "lastname" => "Dalwi", "age" => 45), array("firstname" => "Sahara", "lastname" => "Kilwa", "age" => 45), array("firstname" => "Para", "lastname" => "Jaad", "age" => 18) ); ?>

Continue reading

August 23

List of fetch options in PDO

PDO

Below are the list of the fetch option available in using PDO:

Primitive fetch

  • PDO::FETCH_ASSOC
    Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set.
    If the result set contains multiple columns with the same name, PDO::FETCH_ASSOC returns only a single value per column name.
  • PDO::FETCH_NAMED
    Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set.
    If the result set contains multiple columns with the same name, PDO::FETCH_NAMED returns an array of values per column name.
  • PDO::FETCH_NUM
    Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.
  • PDO::FETCH_BOTH
    Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.

Continue reading

Category: PDO | LEAVE A COMMENT
August 23

What is PDO?

pdo

PDO is the abbrevation of PHP Data Objects. It is a lightweight system or to be precise, it is rather an interface to access data from databases with PHP.

 

How to use PDO?

The PDO system consists of 3 classes: PDO, PDOStatement & PDOException.
The PDO class is responsible for maintaining the database connection doing some conection related stuff (like Transactions) and create the instances of the PDOStatement class.
The PDOStatement class is what you work with most of the time. It is handling the SQL queries and the fetching of the results.
The PDOException class is what you need for error handling.

Continue reading

Category: PDO | LEAVE A COMMENT
August 22

What is PL/SQL?

PL/SQL, then, is an application-development language that is a superset of SQL, supplementing it with standard programming-language features that include the following:

 

  • block (modular) structure
  • flow-control statements and loops
  • variables, constants, and types
  • structured data
  • customized error handling

 

To know more about PL/SQL, click here

Category: PLSQL | LEAVE A COMMENT
August 19

What is Hadoop?

About Hadoop

Apache™ Hadoop® is an open source software project that enables the distributed processing of large data sets across clusters of commodity servers. It is designed to scale up from a single server to thousands of machines, with a very high degree of fault tolerance. Rather than relying on high-end hardware, the resiliency of these clusters comes from the software’s ability to detect and handle failures at the application layer.

 

Click here for more detailed information