Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
George Westrup: "I have saved so much time using your products. Also you are quick to respond to every question I have had. Thanks for the great support".
Grey: "We're a two-person company, it's just me an my wife. I'm the technical guru, and she handles the business operations. I have to know a lot about MySQL, but that's much too technical for her. I have frequently had to setup CGI scripts (I code in Perl) so she can manage some of our tables (suppliers, manufacturers, etc).

I discovered PHP Generator a couple of days ago, tried the free version,and within a few hours I had purchased the Pro version (as well as SQL Maestro for MySQL).

Today I am completing the conversion of the last of my custom table managers to PHP Generator. This is eliminating several thousand lines of code that I don't have to support any more!

Thanks for this fantastic product".

More

Add your opinion

PHP Generator for MySQL online Help

Prev Return to chapter overview Next

Data Partitioning

The Data Partitioning wizard allows you to create a custom pagination i.e. split the records on the generated page by a specified criteria.

 

Select the type of data partitioning on the first wizard step:

Range partitioning

Selects a partition by determining if the partitioning expression value is inside a certain range.

List partitioning

A partition is assigned a list of values. If the partitioning expression value has one of these values, the partition is chosen. For example, all rows where the column 'Country' is either Iceland, Norway, Sweden, Finland or Denmark could build a partition for the 'Nordic countries'.

Custom partitioning

Create your own partitioning with fill partitions and build conditions functions.

To disable data partitioning, select None.

 

Example 1 (Range partitioning)

There is a table storing information about films such as title, release year, and length.

See definition here

 

CREATE TABLE film (

  film_id               integer NOT NULL,

  title                 varchar(255) NOT NULL,

  release_year          integer,

  length                integer UNSIGNED,

  /* Keys */

  PRIMARY KEY (film_id)

);

 

 

To create a pagination by the film length, select Range partitioning at the first wizard step, choose 'length' as partition expression and set the partitioning ranges as follows:

 

 

Here you can see the result PHP script:

 

 

Example 2 (Custom partitioning)

Assume that a table 'customer' contains the 'last_name' column. Our goal is to group customers by the first letter of their last name as displayed below.

 

To get around such a situation, select Custom partitioning and define functions as follows:

 

function GetPartitions($partitions)

{

  $tmp = array();

  $this->GetConnection()->ExecQueryToArray("

    SELECT DISTINCT

      left(c.last_name, 1) as first_letter 

    FROM customer c

    ORDER BY first_letter", $tmp

  );

  foreach($tmp as $letter) {

    $partitions[$letter['first_letter']] = $letter['first_letter']; 

  }

}

 

function GetPartitionCondition($partitionKey, &$condition)

{

  $condition = "left(last_name, 1) = '$partitionKey'";

}



Prev Return to chapter overview Next