PHP Class Ruckusing_Adapter_PgSQL_Base, ruckusing-migrations

Inheritance: extends Ruckusing_Adapter_Base, implements Ruckusing_Adapter_Interface
Datei anzeigen Open project: ruckus/ruckusing-migrations Class Usage Examples

Public Methods

Method Description
__construct ( array $dsn, Ruckusing_Util_Logger $logger ) : Ruckusing_Adapter_PgSQL_Base Creates an instance of Ruckusing_Adapter_PgSQL_Base
__toString ( ) : string Return a message displaying the current version
add_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean Add a column
add_column_options ( string $type, array $options, boolean $performing_change = false ) : string Add column options
add_index ( string $table_name, string $column_name, array $options = [] ) : boolean Add an index
add_timestamps ( string $table_name, string $created_column_name, string $updated_column_name ) : boolean Add timestamps
change_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean Change a column
column_definition ( string $column_name, string $type, array $options = null ) : string Column definition
column_info ( string $table, string $column ) : array Get a column info
commit_transaction ( ) Commit Transaction
create_database ( string $db, array $options = [] ) : boolean Create database cannot run in a transaction block so if we're in a transaction than commit it, do our thing and then re-invoke the transaction
create_schema_version_table ( ) Create the schema table, if necessary
create_table ( string $table_name, array $options = [] ) : boolean | Ruckusing_Adapter_PgSQL_TableDefinition Create table
database_exists ( string $db ) : boolean Check if a db exists
drop_database ( string $db ) : boolean Drop a database
drop_table ( string $tbl ) : boolean Drop table
execute ( $query )
execute_ddl ( string $ddl ) : boolean Use this method for non-SELECT queries Or anything where you dont necessarily expect a result string, e.g. DROPs, CREATEs, etc.
get_database_name ( ) : string Get the current db name
has_index ( string $table_name, string $column_name, array $options = [] ) : boolean Check an index
identifier ( string $string ) : string Quote a string
indexes ( string $table_name ) : array Return all indexes of a table
multi_query ( string $queries ) : boolean Execute several queries
native_database_types ( ) : array Get the column native types
pk_and_sequence_for ( string $table ) : array Returns a table's primary key and belonging sequence.
primary_keys ( string $table_name ) : array get primary keys
query ( string $query ) : boolean Wrapper to execute a query
quote ( string $value, string $column = null ) : string Quote a string
quote_column_name ( string $string ) : string Quote column name
quote_string ( string $string ) : string Escape a string for mysql
quote_table_name ( string $string ) : string Quote table name
remove_column ( string $table_name, string $column_name ) : boolean Drop a column
remove_index ( string $table_name, string $column_name, array $options = [] ) : boolean Drop an index
remove_timestamps ( string $table_name, string $created_column_name, string $updated_column_name ) : boolean Remove timestamps
remove_version ( string $version ) : boolean remove a version
rename_column ( string $table_name, string $column_name, string $new_column_name ) : boolean Rename a column
rename_table ( string $name, string $new_name ) : boolean Renames a table.
rollback_transaction ( ) Rollback Transaction
schema ( string $output_file ) : integer | FALSE Dump the complete schema of the DB. This is really just all of the CREATE TABLE statements for all of the tables in the DB.
select_all ( string $query ) : array Select all
select_one ( string $query ) : array Select one
set_current_version ( string $version ) : boolean Set current version
start_transaction ( ) Start Transaction
supports_migrations ( ) : boolean Check support for migrations
table_exists ( string $tbl, boolean $reload_tables = false ) : boolean Check if a table exists
type_to_sql ( string $type, array $options = [] ) : string Convert type to sql

Private Methods

Method Description
beginTransaction ( ) Start transaction
change_column_default ( string $table_name, string $column_name, string $default ) : boolean Change column default
change_column_null ( string $table_name, string $column_name, string $null, string $default = null ) : boolean Change column null
commit ( ) Commit a transaction
connect ( string $dsn ) Connect to the db
db_connect ( string $dsn ) : boolean Connect to the db
determine_query_type ( string $query ) : integer Check query type
inTransaction ( ) : boolean Check if in transaction
isError ( boolean $o ) : boolean Delegate to PEAR
is_select ( $query_type )
is_sql_method_call ( string $str ) : boolean Detect whether or not the string represents a function call and if so do not wrap it in single-quotes, otherwise do wrap in single quotes.
load_tables ( boolean $reload = true ) Initialize an array of table names
rollback ( ) Rollback a transaction

Method Details

__construct() public method

Creates an instance of Ruckusing_Adapter_PgSQL_Base
public __construct ( array $dsn, Ruckusing_Util_Logger $logger ) : Ruckusing_Adapter_PgSQL_Base
$dsn array The current dsn being used
$logger Ruckusing_Util_Logger the current logger
return Ruckusing_Adapter_PgSQL_Base

__toString() public method

Return a message displaying the current version
public __toString ( ) : string
return string

add_column() public method

Add a column
public add_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$type string the column type
$options array column options
return boolean

add_column_options() public method

Add column options
public add_column_options ( string $type, array $options, boolean $performing_change = false ) : string
$type string the native type
$options array
$performing_change boolean
return string

add_index() public method

Add an index
public add_index ( string $table_name, string $column_name, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$options array index options
return boolean

add_timestamps() public method

Add timestamps
public add_timestamps ( string $table_name, string $created_column_name, string $updated_column_name ) : boolean
$table_name string The table name
$created_column_name string Created at column name
$updated_column_name string Updated at column name
return boolean

change_column() public method

Change a column
public change_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$type string the column type
$options array column options
return boolean

column_definition() public method

Column definition
public column_definition ( string $column_name, string $type, array $options = null ) : string
$column_name string the column name
$type string the type of the column
$options array column options
return string

column_info() public method

Get a column info
public column_info ( string $table, string $column ) : array
$table string the table name
$column string the column name
return array

commit_transaction() public method

Commit Transaction
public commit_transaction ( )

create_database() public method

Create database cannot run in a transaction block so if we're in a transaction than commit it, do our thing and then re-invoke the transaction
public create_database ( string $db, array $options = [] ) : boolean
$db string the db name
$options array
return boolean

create_schema_version_table() public method

Create the schema table, if necessary

create_table() public method

Create table
public create_table ( string $table_name, array $options = [] ) : boolean | Ruckusing_Adapter_PgSQL_TableDefinition
$table_name string the table name
$options array the options
return boolean | Ruckusing_Adapter_PgSQL_TableDefinition

database_exists() public method

Check if a db exists
public database_exists ( string $db ) : boolean
$db string the db name
return boolean

drop_database() public method

Drop a database
public drop_database ( string $db ) : boolean
$db string the db name
return boolean

drop_table() public method

Drop table
public drop_table ( string $tbl ) : boolean
$tbl string the table name
return boolean

execute() public method

public execute ( $query )

execute_ddl() public method

Use this method for non-SELECT queries Or anything where you dont necessarily expect a result string, e.g. DROPs, CREATEs, etc.
public execute_ddl ( string $ddl ) : boolean
$ddl string query to run
return boolean

get_database_name() public method

Get the current db name
public get_database_name ( ) : string
return string

has_index() public method

Check an index
public has_index ( string $table_name, string $column_name, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$options array index options
return boolean

identifier() public method

Quote a string
public identifier ( string $string ) : string
$string string the string
return string

indexes() public method

Return all indexes of a table
public indexes ( string $table_name ) : array
$table_name string the table name
return array

multi_query() public method

Execute several queries
public multi_query ( string $queries ) : boolean
$queries string queries to run
return boolean

native_database_types() public method

Get the column native types
public native_database_types ( ) : array
return array

pk_and_sequence_for() public method

Returns a table's primary key and belonging sequence.
public pk_and_sequence_for ( string $table ) : array
$table string the table name
return array

primary_keys() public method

get primary keys
public primary_keys ( string $table_name ) : array
$table_name string the table name
return array

query() public method

Wrapper to execute a query
public query ( string $query ) : boolean
$query string query to run
return boolean

quote() public method

Quote a string
public quote ( string $value, string $column = null ) : string
$value string the string
$column string the column
return string

quote_column_name() public method

Quote column name
public quote_column_name ( string $string ) : string
$string string the string
return string

quote_string() public method

Escape a string for mysql
public quote_string ( string $string ) : string
$string string the string
return string

quote_table_name() public method

Quote table name
public quote_table_name ( string $string ) : string
$string string the string
return string

remove_column() public method

Drop a column
public remove_column ( string $table_name, string $column_name ) : boolean
$table_name string the table name
$column_name string the column name
return boolean

remove_index() public method

Drop an index
public remove_index ( string $table_name, string $column_name, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$options array index options
return boolean

remove_timestamps() public method

Remove timestamps
public remove_timestamps ( string $table_name, string $created_column_name, string $updated_column_name ) : boolean
$table_name string The table name
$created_column_name string Created at column name
$updated_column_name string Updated at column name
return boolean

remove_version() public method

remove a version
public remove_version ( string $version ) : boolean
$version string the version
return boolean

rename_column() public method

Rename a column
public rename_column ( string $table_name, string $column_name, string $new_column_name ) : boolean
$table_name string the table name
$column_name string the column name
$new_column_name string the new column name
return boolean

rename_table() public method

Also renames a table's primary key sequence if the sequence name matches the Ruckusing Migrations default.
public rename_table ( string $name, string $new_name ) : boolean
$name string the current table name
$new_name string the new table name
return boolean

rollback_transaction() public method

Rollback Transaction

schema() public method

NOTE: this does NOT include any INSERT statements or the actual data
public schema ( string $output_file ) : integer | FALSE
$output_file string the filepath to output to
return integer | FALSE

select_all() public method

Select all
public select_all ( string $query ) : array
$query string query to run
return array

select_one() public method

Select one
public select_one ( string $query ) : array
$query string query to run
return array

set_current_version() public method

Set current version
public set_current_version ( string $version ) : boolean
$version string the version
return boolean

start_transaction() public method

Start Transaction
public start_transaction ( )

supports_migrations() public method

Check support for migrations
public supports_migrations ( ) : boolean
return boolean

table_exists() public method

Check if a table exists
public table_exists ( string $tbl, boolean $reload_tables = false ) : boolean
$tbl string the table name
$reload_tables boolean reload table or not
return boolean

type_to_sql() public method

Convert type to sql
public type_to_sql ( string $type, array $options = [] ) : string
$type string the native type
$options array
return string