\Pluf_DB_Schema

Create the schema of a given Pluf_Model for a given database.

Summary

Methods
Properties
Constants
__construct()
getGenerator()
createTables()
createConstraints()
dropTables()
dropConstraints()
quoteColumn()
$model
$schema
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$con
N/A

Properties

$model

$model : 

Model from which the schema is generated.

Type

$schema

$schema : 

Schema generator object corresponding to the database.

Type

$con

$con : 

Database connection object.

Type

Methods

__construct()

__construct(  $db,   $model = null) 

Parameters

$db
$model

getGenerator()

getGenerator() : object

Get the schema generator.

Returns

object —

Pluf_DB_Schema_XXXX

createTables()

createTables() : mixed

Create the tables and indexes for the current model.

If the model is a mapped model ($model->_a['mapped'] == true) then only tables for its many to many relations will be created and table for the model will not be created.

A mapped model is a model which have not a separate table. In other word, a mapped model is a specific view to another model and is not a real model.

A mapped model may defines some new many to many relations which was not defined in the main model.

Returns

mixed —

True if success or database error.

createConstraints()

createConstraints() 

Creates the constraints for the current model.

This should be done after all tables of all models have been created.

Throws

\Pluf\Exception

dropTables()

dropTables() : mixed

Drop the tables and indexes for the current model.

Returns

mixed —

True if success or database error.

dropConstraints()

dropConstraints() : boolean

Drops the constraints for the current model.

This should be done before all tables of all models are dropped.

Throws

\Pluf\Exception

Returns

boolean

quoteColumn()

quoteColumn(  $col,   $db) : string

Given a column name or a string with column names in the format "column1, column2, column3", returns the escaped correctly quoted column names.

This is good for index creation.

Parameters

$col
$db

Returns

string —

Quoted for the DB column(s)