Use Posql with CakePHP - Posql - CakePHP HowTo

This document is the one that most of sentences was translated literally into English from Japanese. Therefore, please acknowledge it though there is a possibility with improper sentences.
You can refer the original Japanese document.

Index


CakePHP Posql driver overview

This document explains the procedure to use Posql as a database (DBO driver) from CakePHP that is PHP framework.

Posql is database engine (DBMS) of pure PHP. Refer to Posql SQL Reference for a detailed outline and the supported SQL grammar if you want more informations.

From Posql Version 2.09. DBO driver 'dbo_posql.php' to be able to use Posql with CakePHP and the configuration file etc are bundled to the package.

Posql current version is 2.17 stable.


Confirmed operating version

Posql Version
2.09 later (Current Stable Version: 2.17)
CakePHP Version
1.2.4 / 1.2.5 (1.2.x)
PHP Version
PHP 4.3+ / PHP 5

Download


Install

  1. Download Posql Version 2.17 (If you have not yet).

    There is a directory named CakePHP-DBO-Posql in the Posql package, and it becomes target directory.
    It becomes the following directory compositions.

    • CakePHP-DBO-Posql/cake/libs/model/datasources/dbo/dbo_posql.php

      The DBO driver Posql for the CakePHP framework.
    • CakePHP-DBO-Posql/app/config/database.php.posql

      The database configuration file.
    • CakePHP-DBO-Posql/app/vendors/posql/posql.php

      The main file of the Posql database class.

  2. Copy all the file directories (app and cake directory) which exist in directory CakePHP-DBO-Posql in the Posql package onto the right under directory of the main body of the CakePHP framework (directory with app, cake, and vendors).

    Note: The composition of the directory in CakePHP-DBO-Posql is the same as the CakePHP framework.

    It becomes setting on the CakePHP framework side after this.

  3. Delete all present cache if existed.
  4. Set the file path of the database in the database configuration file.
    This setting can be basically treated just like the SQLite DBO driver.
    The database configuration file was sure to be copied onto

    app/config/database.php.posql

    Rename to original 'database.php' a suitable filename and it to backup.
    Rename 'database.php.posql' to 'database.php'.
     var $default = array(
       'driver'     => 'posql',
       'persistent' => false,
       'host'       => '',
       'login'      => '',
       'password'   => '',
       'database'   => '../vendors/posql/database_name.php',
       'prefix'     => '',
     ); 
    the state of default as feeling above.
    Settings:

    '../vendors/posql/database_name.php'

    Look the part the key is 'database'. This becomes the file path of the database. In default, it is set to the same directory as main class file 'posql.php' by the relative path.
    Change 'database_name.php' which hits the database name to your suitable database name. Change also the target directory if necessary. Change to the absolute path from the relative path if possible.
    Set the permissions of target directory to enables writing and enables reading.
    Note: There is a possibility that the database cannot be recognized when '.php' of the extension is changed.
    Even if the value is set, 'login' and 'password' are disregarded as well as SQLite.

Bug report

Only a minimum test is done though the Posql driver is taken to confirm the operation. A complex SQL statement is not tested. There is a trouble possibility when SQL sentence is originally issued. Please try in consideration of the respect.

Post from the forum in GitHub - Posql if there are a demand, an impression, trouble, and a bug report, etc.


GitHub - Posql
GitHub - Posql
CakePHP
CakePHP: Rapid Development Framework
PHP
PHP: Hypertext Preprocessor