Skip to content
This repository was archived by the owner on Oct 11, 2019. It is now read-only.

Table Tools

circlecreative edited this page Dec 16, 2014 · 4 revisions

This functions is for helping you create, alter, truncate, empty or delete table.

O2ORM::$db->table->drop('table_name');


Using example:

O2ORM::$db->table->drop('table_name'); // single table
O2ORM::$db->table->drop(['table1','table2']); // multiple table

returns num of tables are being successfully dropped.

O2ORM::$db->table->empty_table('table_name');


Using example:

O2ORM::$db->table->empty_table('table_name'); // single table
O2ORM::$db->table->empty_table(['table1','table2']); // multiple table

returns num of tables are being successfully empty.

O2ORM::$db->table->truncates('table_name');


Using example:

O2ORM::$db->table->truncates('table_name'); // single table
O2ORM::$db->table->truncates(['table1','table2']); // multiple table

returns num of tables are being successfully truncated.

These functions let you fetch table information.

O2ORM::$db->table->lists();


Using example:

$tables = O2ORM::$db->table->lists();

foreach ($tables as $table)
{
   echo $table;
}

returns list of tables in array

O2ORM::$db->table->exists('table_name');


Sometimes it's helpful to know whether a particular table exists before running an operation on it. Returns a boolean TRUE/FALSE. Usage example:

if (O2ORM::$db->table->exists('table_name'))
{
   // some code...
}

returns true or false (Boolean)

O2ORM::$db->table->metadata('table_name');


This tools gives you complete information about the table, such as: fields, primary keys, indexes and etc.

returns Table Metadata Objects