[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> install-helper.php (summary)

Plugins may load this file to gain access to special helper functions for plugin installation. This file is not included by WordPress and it is recommended, to prevent fatal errors, that this file is included using require_once. These functions are not optimized for speed, but they should only be used once in a while, so speed shouldn't be a concern. If it is and you are needing to use these functions a lot, you might experience time outs. If you do, then it is advised to just write the SQL code yourself.

File Size: 210 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 functions

  maybe_create_table()
  maybe_add_column()
  maybe_drop_column()
  check_column()

Functions
Functions that are not part of a class:

maybe_create_table( $table_name, $create_ddl )   X-Ref
Creates a table in the database if it doesn't already exist.

return: bool True on success or if the table already exists. False on failure.
param: string $table_name Database table name.
param: string $create_ddl SQL statement to create table.
since: 1.0.0

maybe_add_column( $table_name, $column_name, $create_ddl )   X-Ref
Adds column to database table, if it doesn't already exist.

return: bool True on success or if the column already exists. False on failure.
param: string $table_name  Database table name.
param: string $column_name Table column name.
param: string $create_ddl  SQL statement to add column.
since: 1.0.0

maybe_drop_column( $table_name, $column_name, $drop_ddl )   X-Ref
Drops column from database table, if it exists.

return: bool True on success or if the column doesn't exist. False on failure.
param: string $table_name  Database table name.
param: string $column_name Table column name.
param: string $drop_ddl    SQL statement to drop column.
since: 1.0.0

check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default_value = null, $extra = null )   X-Ref
Checks that database table column matches the criteria.

Uses the SQL DESC for retrieving the table info for the column. It will help
understand the parameters, if you do more research on what column information
is returned by the SQL statement. Pass in null to skip checking that
criteria.

Column names returned from DESC table are case sensitive and are listed:
Field
Type
Null
Key
Default
Extra

return: bool True, if matches. False, if not matching.
param: string $table_name    Database table name.
param: string $col_name      Table column name.
param: string $col_type      Table column type.
param: bool   $is_null       Optional. Check is null.
param: mixed  $key           Optional. Key info.
param: mixed  $default_value Optional. Default value.
param: mixed  $extra         Optional. Extra value.
since: 1.0.0



Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1