CakePHP3 Tutorial

Next: Creating View, Controller and Table for Entering Data UP: TOC

Let's create a database which will be used in CakePHP 3

su - pgsql
$ createdb --encoding=UTF8 db20150612
$ exit


psql -d db20150612 -U pgsql 
psql (9.3.8)
Type "help" for help.

create table user (
   id character(36) primary key,
   nick character varying(24) not null,
   email character varying (255) not null,
   zw character varying (64),
   lang character(2) default 'de',
   last_login timestamp with time zone,
   created  timestamp with time zone DEFAULT ('now'::text)::timestamp 
       with time zone,
   modified timestamp with time zone DEFAULT ('now'::text)::timestamp   
       with time zone,
   pw_reset_time timestamp with time zone
) with (oids = false);

CREATE TABLE
create unique index user_email on user(email);

Let CakePHP know to which database it has to connect. The config file is located in .../src/config/app.php

   'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Postgres',
            'persistent' => false,
            'host' => 'localhost',
            //'port' => 'nonstandard_port_number',
            'username' => 'pgsql',
            'password' => 'dont-tell-us',
            'database' => 'db1',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'cacheMetadata' => true,

            /**
             * Set identifier quoting to true if you are using reserved words or
             * special characters in your table or column names. Enabling this
             * setting will result in queries built using the Query Builder having
             * identifiers quoted when creating SQL. It should be noted that this
             * decreases performance because each query needs to be traversed and
             * manipulated before being executed.
             */
            'quoteIdentifiers' => false,

            /**
             * During development, if using MySQL < 5.6, uncommenting the
             * following line could boost the speed at which schema metadata is
             * fetched from the database. It can also be set directly with the
             * mysql configuration directive 'innodb_stats_on_metadata = 0'
             * which is the recommended value in production environments
             */
            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
        ],Next: Creating View, Controller and Table for Entering Data  UP: TOC