Common Database Library



( ZN >= 3.0.0 )

This library contains common methods that can be used on all other database libraries. All of the methods shown below can be used in DB :: , DBForge :: , DBTool :: , DBTrigger :: and DBUser :: libraries.

 

 

# Methods


this table ( String $ table )
this column ( String $ col , Scalar $ val = NULL )
this secure ( Array $ data )
String error ( Void )
String version ( Void )
Object differentConnection ( Mixed $ connectName )
String stringQuery ( Void )
this string ( Void )

 

 

# Table ( ZN >= 3.0.0 )


This method has been created as an optional use as an alternative to this parameter of the methods that require table names .

Parameters
String $ Table Table name.
return this
uses
DB::table('test')->get()->result();
DBForge::table('test')->dropTable();

 

 

# Column ( ZN >= 3.0.0 )


This method can be used with database methods that require column information.

Parameters

String $ columna Colon information.
Mixed $ data = NULL Column value.
return this

uses

DB::table('test')
  ->column('name', 'Example')
  ->column('phone', '12345')
  ->insert();
DBForge::table('users')->column('name')->column('address')->dropColumn();

 

 

# Secure ( ZN> = 2.0.0 )


This method can be used with methods that require security input.

Parameters
Array $ data The array of data that will be secured.
return this
uses
DB::secure(['zn', '4'])
  ->query('SELECT * FROM WHERE framework = "?" and version = ?');

 

 

# Error ( ZN >= 0.0.1 )


Returns whether the query result is an error.

Parameters
void
return String
uses 
DB::query('SELECT * FROM');

echo DB::error();
DBForge::createTable('table', []);

echo DBForge::error();

 

 

# Version ( ZN >= 0.0.1 )


Gives version information of the current database platform.

Parameters
void
return String
uses 
echo DB::version();

 

 

# DifferentConnection ( ZN> = 2.0.0 )


Used to create a different database connection. Sometimes you may need to work with several different databases. This is the method you will use in such cases.

Parameters
Mixed $ config Used to create a new connection except for the default settings. Both the array and the string type can take values.
return this
uses
$different = DB::differentConnection(['database' => 'differentDatabase']);

$different->insert('table', ['name' => 'ZN']);
$differentForge = DBForge::differentConnection(['database' => 'differentDatabase']);

$differentForge->dropTable('table');

 

 

# StringQuery ( ZN >= 3.0.0 )


The use of this method returns the string SQL string of the most recent query .

Parameters
void
return String
uses
DB::get('users');

echo DB::stringQuery(); # SELECT * FROM users

 

 

# S tring ( ZN >= 3.0.0 )


Used to retrieve the string counter of any SQL query .

Parameters
void
return String
uses
DB::string()->get('users');
SELECT * FROM USERS