The primitive types
Here is a list of primitive data types supported in EZPDO.
- bool
- int(m)
- decimal(m,d)
- float(m)
- char(m)
- clob(m)
- blob(m)
- date
- time
- datetime
bool, int, float
Boolean, int, and float are the same as those defined in PHP and are simply mapped to the corresponding default database column types.
char, clob, blob
The types, char/clob/blob, are for PHP strings, of which char is for relatively short text string, clob for long strings, and blob for long binary strings. You can use parameter “(m)” to specify the maximum length for the char/clob/blob column. By default, m is 512.
data, time and datetime
For simplicity, the data, time, and datatime types are all simply modeled as Unix timestamp (the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) and are mapped to int(16) in database.
Summary of primitive types
The following table summarizes the supported data types.
| type | alias(es) | parameters | comments |
|---|---|---|---|
| bool | boolean, bit | Mapped as 1-byte integer | |
| int(m) | integer(m) | m: Number of digits | Maped as m-type signed integer |
| decimal(m,d) | m: total digits, d: digits after decimal point | ||
| float(m) | real(m) | m: Precision | Synonym for ANSI real |
| char(m) | m: Number of bytes | Mapped as VARCHAR | |
| clob(m) | text(m) | m: Number of bytes | Long text string |
| blob(m) | m: Number of bytes | Long binary string | |
| date | Modeled as unix time, int(16) | ||
| time | Modeled as unix time, int(16) | ||
| datetime | Modeled as unix time, int(16) |
Keep in mind that if parameter (m) is not specified, it is default to the default value of the underlying database column type.
Too few types?
As you may have noticed, the types listed above are far fewer than the column types any specific database supports. Take the popular MySQL for example, version 5 supports more than 20 column types.
We choose to use as few data types as possible for simplicity so to ease the ORM specification task for the user. EZPDO makes the decision on how to map them to the column types of a specific database.
Beyond primitive types
So we have addressed the primitive data types. What about the complex ones? Objects and arrays? For those non-primitive data types, they have everything to do with object relationships that we address in object relationships.