Database Property Types



( ZN >= 3.0.0 )

In this section, we will show how to use common types of attributes that differ according to database drivers. Below is a table showing the variation of data types according to database platforms.

MySQL Postgres SQLite SQLServer ODBC Oracle
AUTO_INCREMENT BIGSERIAL AUTOINCREMENT IDENTITY (1,1) AUTOINCREMENT CREATE SEQUENCE ...
PRIMARY KEY PRIMARY KEY PRIMARY KEY PRIMARY KEY PRIMARY KEY PRIMARY KEY
FOREIGN KEY FOREIGN KEY FOREIGN KEY FOREIGN KEY FOREIGN KEY FOREIGN KEY
UNIQUE UNIQUE UNIQUE UNIQUE UNIQUE UNIQUE
NULL NULL NULL NULL NULL NULL
NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL
EXISTS EXISTS EXISTS EXISTS EXISTS EXISTS
NOT EXISTS NOT EXISTS NOT EXISTS NOT EXISTS NOT EXISTS NOT EXISTS
CONSTRAINT CONSTRAINT CONSTRAINT CONSTRAINT CONSTRAINT CONSTRAINT
DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT
LIKE :% LIKE :% LIKE :% LIKE :% LIKE : * LIKE :%

Methods have been developed according to these types of qualities to achieve the above differences. An example of how to use these methods is given below.

 

 

# Methods


Below is the list of attribute types of DB :: library.

String autoIncrement ( String $ col = NULL , Bool $ type = true )
String primaryKey ( String $ col = NULL , Boolean $ type = true )
String ForeignKey ( String $ col = NULL , Boolean $ type = true )
String unique ( String $ col = NULL , Bool $ type = true )
String null ()
String notnull ()
String exists ( String $ col = NULL , Bool $ type = true )
String notexists ( String $ col = NULL , Boolean $ type = true )
String constraint ( String $ constraint = NULL , Bool $ type = false )
String DefaultValue ( string $ default = NULL , Boolean $ type = false )
String like ( String $ value , String $ type = 'starting' )
String between ( String $ value1 , String $ value2 )
String in ( String ... $ value )
String inTable ( String ... $ value )
String inQuery ( String ... $ value )
String The NotI (String ... $ value )

 

 

# AutoIncrement ( ZN> = 3.0.0 )


SQL is the equivalent of the AUTO_INCREMENT statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::autoIncrement(); # AUTOINCREMENT

 

 

# PrimaryKey ( ZN >= 3.0.0 )


The counterpart of the SQL PRIMARY KEY statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::primaryKey(); # PRIMARY KEY

 

 

# ForeignKey ( ZN >= 3.0.0 )


Equivalent to the SQL FOREIGN KEY statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::foreignKey(); # FOREIGN KEY

 

 

# Unique ( ZN >= 3.0.0 )


SQL stands for UNIQUE statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::unique(); # UNIQUE

 

 

# Null ( ZN >= 3.0.0 )


SQL is the equivalent of the NULL statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::null(); # NULL

 

 

# NotNull ( ZN >= 3.0.0 )


This is the counterpart of the SQL NOT NULL statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::notNull(); # NOT NULL

 

 

# Exists ( ZN >= 4.0.1-EIP )


It is the equivalent of the SQL EXIST statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::exists('...DATA...'); # EXISTS(...DATA...)

 

 

# NotExists ( ZN> = 4.0.1-EIP )


MYSQL stands for the statement NOT EXISTS . However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::notExists(); # NOT EXISTS

 

 

# Constraint ( ZN >= 3.0.3 )


SQL stands for CONSTRAINT statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::constraint(); # CONSTRAINT

 

 

# DefaultValue ( ZN >= 3.0.3 )


MYSQL is the equivalent of the DEFAULT statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

echo DB::defaultValue(10); # DEFAULT(10)

 

 

# Like ( ZN >= 2.0.0 )


SQL stands for LIKE statement. However, according to the above table, the output of the method varies according to the type of the selected database drive.

Parameters
String $ data The string to search.
String $ type = 'starting' It's the type of search.
starting beginning with
inside ... passing through ...
ending Ending with ....
return String
Use of
echo DB::like('search', 'inside');   # %search%
echo DB::like('search', 'starting'); # search%
echo DB::like('search', 'ending');   # %search 
echo DB::where('exampleColumn like', DB::like('searchData', 'starting'))
       ->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn like 'searchData%' 

 

 

# Between ( ZN >= 4.2.6 )


SQL BETWEEN value is the AND value of the value statement.

Parameters
String $ value1 The 1st value to compare .
String $ value2 The second value to compare .
return String
Use of
echo DB::where('exampleColumn between', DB::between(1, 2))->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn between 1 AND 2

 

 

# In ( ZN >= 4.2.6 )


SQL IN ( 'val1' , 'val2' ) is the counterpart of the statement.

Parameters
String ... $ values Sequential parametric values.
return String
Use of
echo DB::where('exampleColumn in', DB::in('London', 'Istanbul', 10))
       ->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn in ( 'London' , 'Istanbul' , 10

 

 

# InTable ( ZN >= 4.2.6 )


It is the equivalent of the SQL IN (SELECT * FROM TABLE) statement.

Parameters

String ... $ values Sequential parametric values.
return String

Use of

echo DB::where('exampleColumn in', DB::inTable('exampleTable2'))
       ->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn in ( SELECT * FROM exampleTable2) 

 

 

# InQuery ( ZN >= 4.2.6 )


It is the equivalent of the SQL IN (SELECT * FROM TABLE) statement.

Parameters
String ... $ values Sequential parametric values.
return String
Use of
echo DB::where('exampleColumn in', DB::inQuery(DB::getString('exampleTable2')))
       ->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn in ( SELECT * FROM exampleTable2) 

 

 

# NotIn ( ZN >= 4.2.6 )


It is the equivalent of the SQL NOT IN (...) statement.

Parameters
String ... $ values Sequential parametric values.
return String
Use of
echo DB::where('exampleColumn not in', DB::notIn(DB::getString('exampleTable2')))
       ->getString('exampleTable');
SELECT * FROM exampleTable WHERE exampleColumn not in ( SELECT * FROM exampleTable2)