File: test/test2.js

Recommend this page to a friend!
  Classes of Nikos M.  >  Dialect PHP SQL Query Builder  >  test/test2.js  >  Download  
File: test/test2.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Dialect PHP SQL Query Builder
Build SQL queries from templates
Author: By
Last change: Update of test/test2.js
Date: 3 months ago
Size: 1,371 bytes
 

Contents

Class file image Download
var Dialect = require("../src/js/Dialect.js"), echo = console.log;

echo('Dialect.VERSION = ' + Dialect.VERSION)
echo( );

var dialect = new Dialect( 'mysql' );

echo(dialect.Create('new_table', {
    ifnotexists: true,
    columns: [
        {column:'id', type:'bigint(20)', isnotnull:1, auto_increment:1},
        {column:'name', type:'tinytext', isnotnull:1, default_value:"''"},
        {column:'categoryid', type:'bigint(20)', isnotnull:1, default_value:0},
        {column:'companyid', type:'bigint(20)', isnotnull:1, default_value:0},
        {column:'fields', type:'text', isnotnull:1, default_value:"''"},
        {column:'start', type:'datetime', isnotnull:1, default_value:"'0000-00-00 00:00:00'"},
        {column:'end', type:'datetime', isnotnull:1, default_value:"'0000-00-00 00:00:00'"},
        {column:'status', type:'tinyint(8) unsigned', isnotnull:1, default_value:0},
        {column:'extra', type:'text', isnotnull:1, default_value:"''"},
        {key:['categoryid'], name:'categoryid'},
        {key:['companyid'], name:'companyid'},
        {uniquekey:['id'], name:'id', constraint:'constraint_name'}
    ],
    table: [
        {collation:'utf8_general_ci'}
    ]
}).sql());

echo();

echo(dialect.Create('new_view', {
    view: true,
    ifnotexists: true,
    columns: ['id', 'name'],
    query: 'SELECT id, name FROM another_table'
}).sql());


For more information send a message to info at phpclasses dot org.