- mercromina responded to »error when i try to upgrade to the last version of dizkus module (3.1)« 08:01 PM
- craigh responded to »TagIt 3.0 for Zikula« 03:58 PM
- localrags responded to »Remove contents of nuke_sc_anticracker from Database« 11:30 AM
- jmvaughn responded to »Shoutit for zikula 1.3?« 09:31 AM
- mdee responded to »Different page content under one template (tpl file) based on URL« 07:17 AM
- espaan responded to »Categories disappear when editing ...« 08. Feb
- eledril responded to »How decrease zikula cpu usage« 08. Feb
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Wiki » AdodbDataDictionary
Additions
See also this forum topic∞ about large fields and what size they are.
Deletions
See also this forum topice∞ about large fields and what size they are.
Additions
ADODB Data Dictionary
DBUtil uses the ADODB data dictionary. This is a way to specify a database table's structure in a generic way. For clarity we will refer to fields as columns or fields interchangably. DBUtil will then be able create the database according to whichever rule are required internally. This leaves you free from worying about making your web application work in different database environments. You can get more detailed information from the ADODB documentation at http://phplens.com/lens/adodb/docs-datadict.htm∞
Column types
We can specify column type with this code:
- C: Varchar, capped to 255 characters.
- X: Larger varchar, capped to 4000 characters (to be compatible with Oracle).
- XL: For Oracle, returns CLOB, otherwise the largest varchar size.
- C2: Multibyte varchar
- X2: Multibyte varchar (largest size)
- B: BLOB (binary large object)
- D: Date (some databases do not support this, and we return a datetime type)
- T: Datetime or Timestamp
- L: Integer field suitable for storing booleans (0 or 1)
- I: Integer (mapped to I4)
- I1: 1-byte integer
- I2: 2-byte integer
- I4: 4-byte integer
- I8: 8-byte integer
- F: Floating point number
- N: Numeric or decimal number
See also this forum topice∞ about large fields and what size they are.
Column options
Each column can have additional options
- AUTO For autoincrement number. Emulated with triggers if not available. Sets NOTNULL also.
- AUTOINCREMENT Same as auto.
- KEY Primary key field. Sets NOTNULL also. Compound keys are supported.
- PRIMARY Same as KEY.
- DEF Synonym for DEFAULT for lazy typists.
- DEFAULT The default value. Character strings are auto-quoted unless the string begins and ends with spaces, eg ' SYSDATE '.
- NOTNULL If field is not null.
- DEFDATE Set default value to call function to get today's date.
- DEFTIMESTAMP Set default to call function to get today's datetime.
- NOQUOTE Prevents autoquoting of default string values.
- CONSTRAINTS Additional constraints defined at the end of the field definition.
Dictionary Example
Data dictionaries are specified as strings. So now we can provide an example:
$sql = "id I NOTNULL AUTO PRIMARY,
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
This will create a table with 4 columns called id, title, content and online
id will be an integer field, NULL values not allowed, will be auto numbered (if supported), will be used as the primary index.
title will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
content will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
online will be a boolean suitable integer field limited to on digit, NULL values not allowed, and default value will be 0
You will see how the field type can take extra numbers in brackets, examples:
- C(10) means VARCHAR with 10 characters
- F(6.2) means a FLOAT type with nnnnnn.xx
You should become familiar with this format.
CategoryDeveloperDocs
Deletions
ADODB Data Dictionary
DBUtil uses the ADODB data dictionary. This is a way to specify a database table's structure in a generic way. For clarity we will refer to fields as columns or fields interchangably. DBUtil will then be able create the database according to whichever rule are required internally. This leaves you free from worying about making your web application work in different database environments. You can get more detailed information from the ADODB documentation at http://phplens.com/lens/adodb/docs-datadict.htm∞
Column types
We can specify column type with this code:
- C: Varchar, capped to 255 characters.
- X: Larger varchar, capped to 4000 characters (to be compatible with Oracle).
- XL: For Oracle, returns CLOB, otherwise the largest varchar size.
- C2: Multibyte varchar
- X2: Multibyte varchar (largest size)
- B: BLOB (binary large object)
- D: Date (some databases do not support this, and we return a datetime type)
- T: Datetime or Timestamp
- L: Integer field suitable for storing booleans (0 or 1)
- I: Integer (mapped to I4)
- I1: 1-byte integer
- I2: 2-byte integer
- I4: 4-byte integer
- I8: 8-byte integer
- F: Floating point number
- N: Numeric or decimal number
Column options
Each column can have additional options
- AUTO For autoincrement number. Emulated with triggers if not available. Sets NOTNULL also.
- AUTOINCREMENT Same as auto.
- KEY Primary key field. Sets NOTNULL also. Compound keys are supported.
- PRIMARY Same as KEY.
- DEF Synonym for DEFAULT for lazy typists.
- DEFAULT The default value. Character strings are auto-quoted unless the string begins and ends with spaces, eg ' SYSDATE '.
- NOTNULL If field is not null.
- DEFDATE Set default value to call function to get today's date.
- DEFTIMESTAMP Set default to call function to get today's datetime.
- NOQUOTE Prevents autoquoting of default string values.
- CONSTRAINTS Additional constraints defined at the end of the field definition.
Dictionary Example
Data dictionaries are specified as strings. So now we can provide an example:
$sql = "id I NOTNULL AUTO PRIMARY,
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
This will create a table with 4 columns called id, title, content and online
id will be an integer field, NULL values not allowed, will be auto numbered (if supported), will be used as the primary index.
title will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
content will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
online will be a boolean suitable integer field limited to on digit, NULL values not allowed, and default value will be 0
You will see how the field type can take extra numbers in brackets, examples:
- C(10) means VARCHAR with 10 characters
- F(6.2) means a FLOAT type with nnnnnn.xx
You should become familiar with this format.
CategoryDeveloperDocs
ADODB Data Dictionary
DBUtil uses the ADODB data dictionary. This is a way to specify a database table's structure in a generic way. For clarity we will refer to fields as columns or fields interchangably. DBUtil will then be able create the database according to whichever rule are required internally. This leaves you free from worying about making your web application work in different database environments. You can get more detailed information from the ADODB documentation at http://phplens.com/lens/adodb/docs-datadict.htm∞
Column types
We can specify column type with this code:
- C: Varchar, capped to 255 characters.
- X: Larger varchar, capped to 4000 characters (to be compatible with Oracle).
- XL: For Oracle, returns CLOB, otherwise the largest varchar size.
- C2: Multibyte varchar
- X2: Multibyte varchar (largest size)
- B: BLOB (binary large object)
- D: Date (some databases do not support this, and we return a datetime type)
- T: Datetime or Timestamp
- L: Integer field suitable for storing booleans (0 or 1)
- I: Integer (mapped to I4)
- I1: 1-byte integer
- I2: 2-byte integer
- I4: 4-byte integer
- I8: 8-byte integer
- F: Floating point number
- N: Numeric or decimal number
Column options
Each column can have additional options
- AUTO For autoincrement number. Emulated with triggers if not available. Sets NOTNULL also.
- AUTOINCREMENT Same as auto.
- KEY Primary key field. Sets NOTNULL also. Compound keys are supported.
- PRIMARY Same as KEY.
- DEF Synonym for DEFAULT for lazy typists.
- DEFAULT The default value. Character strings are auto-quoted unless the string begins and ends with spaces, eg ' SYSDATE '.
- NOTNULL If field is not null.
- DEFDATE Set default value to call function to get today's date.
- DEFTIMESTAMP Set default to call function to get today's datetime.
- NOQUOTE Prevents autoquoting of default string values.
- CONSTRAINTS Additional constraints defined at the end of the field definition.
Dictionary Example
Data dictionaries are specified as strings. So now we can provide an example:
$sql = "id I NOTNULL AUTO PRIMARY,
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
title C(255) NOTNULL DEFAULT '',
content C(255) NOTNULL DEFAULT '',
online L NOTNULL DEFAULT 0";
This will create a table with 4 columns called id, title, content and online
id will be an integer field, NULL values not allowed, will be auto numbered (if supported), will be used as the primary index.
title will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
content will be a VARCHAR field with a limit of 255 characters, NULL values not allowed, and default value will be
online will be a boolean suitable integer field limited to on digit, NULL values not allowed, and default value will be 0
You will see how the field type can take extra numbers in brackets, examples:
- C(10) means VARCHAR with 10 characters
- F(6.2) means a FLOAT type with nnnnnn.xx
You should become familiar with this format.
CategoryDeveloperDocs
CategoryReference
