PHP Classes

File: test/js/test2.js

Recommend this page to a friend!
  Classes of Nikos M.  >  Dialect PHP SQL Query Builder  >  test/js/test2.js  >  Download  
File: test/js/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: v.1.4.0 contd

* support default values in sql_function, sql_type
* more standard and versatile sql types supported
* add JSON sql type
Date: 2 months ago
Size: 1,551 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.clear().Create('new_table', { ifnotexists: true, columns: [ {column:'id', type:dialect.sql_type('bigint',[20]), isnotnull:1, auto_increment:1}, {column:'name', type:dialect.sql_type('varchar',[100]), isnotnull:1, default_value:"''"}, {column:'categoryid', type:dialect.sql_type('bigint',[20]), isnotnull:1, default_value:0}, {column:'companyid', type:dialect.sql_type('bigint',[20]), isnotnull:1, default_value:0}, {column:'fields', type:dialect.sql_type('text'), isnotnull:1, default_value:"''"}, {column:'start', type:dialect.sql_type('datetime'), isnotnull:1, default_value:"'0000-00-00 00:00:00'"}, {column:'end', type:dialect.sql_type('datetime'), isnotnull:1, default_value:"'0000-00-00 00:00:00'"}, {column:'status', type:dialect.sql_type('smallint',[8]), isnotnull:1, default_value:0}, {column:'extra', type:dialect.sql_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.clear().Create('new_view', { view: true, ifnotexists: true, columns: ['id', 'name'], query: 'SELECT id, name FROM another_table' }).sql());