[ 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.

param: string $table_name Database table name.
param: string $create_ddl SQL statement to create table.
return: bool True on success or if the table already exists. False on failure.
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.

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

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

param: string $table_name  Database table name.
param: string $column_name Table column name.
param: string $drop_ddl    SQL statement to drop column.
return: bool True on success or if the column doesn't exist. False on failure.
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

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.
return: bool True, if matches. False, if not matching.
since: 1.0.0



Generated: Thu Apr 18 01:00:02 2024 Cross-referenced by PHPXref 0.7.1