DB
in package
Table of Contents
- $wpdb : mixed
- $databaseName : mixed
- $host : mixed
- $password : mixed
- $table : mixed
- $tablePrefix : mixed
- $username : mixed
- __construct() : mixed
- all() : null|array<string|int, mixed>
- Fetch all records from the table.
- find() : null|array<string|int, mixed>
- Find a specific record by ID.
- getOption() : mixed
- Retrieve an option value from the wp_options table.
- getUser() : object|null
- getUserMeta() : mixed
- table() : static
- tableExist() : mixed
- where() : null|object
- Get records based on a specified condition.
- dbConnect() : PDO
- Establish and return a PDO database connection.
- isSerialized() : bool
- Check if a given string is serialized.
- maybeUnserialize() : mixed
- Unserialize data if it is serialized.
Properties
$wpdb
protected
mixed
$wpdb
$databaseName
private
mixed
$databaseName
$host
private
mixed
$host
$password
private
mixed
$password
$table
private
mixed
$table
$tablePrefix
private
mixed
$tablePrefix
$username
private
mixed
$username
Methods
__construct()
public
__construct(string $host, string $databaseName, string $username, string $password[, string $tablePrefix = 'wp_' ]) : mixed
Parameters
- $host : string
- $databaseName : string
- $username : string
- $password : string
- $tablePrefix : string = 'wp_'
Return values
mixed —all()
Fetch all records from the table.
public
all() : null|array<string|int, mixed>
Return values
null|array<string|int, mixed> —find()
Find a specific record by ID.
public
find(int $id) : null|array<string|int, mixed>
Parameters
- $id : int
Return values
null|array<string|int, mixed> —getOption()
Retrieve an option value from the wp_options table.
public
getOption(string $optionName[, mixed $default = null ]) : mixed
Parameters
- $optionName : string
- $default : mixed = null
Return values
mixed —getUser()
public
getUser(string $user_login) : object|null
Parameters
- $user_login : string
Return values
object|null —getUserMeta()
public
getUserMeta(int $userId, string $metaKey[, mixed $default = null ]) : mixed
Parameters
- $userId : int
- $metaKey : string
- $default : mixed = null
Return values
mixed —table()
public
table([string $table_name_no_prefix = 'options' ]) : static
Parameters
- $table_name_no_prefix : string = 'options'
Return values
static —tableExist()
public
tableExist() : mixed
Return values
mixed —where()
Get records based on a specified condition.
public
where(string $column, string $value) : null|object
Parameters
- $column : string
- $value : string
Return values
null|object —dbConnect()
Establish and return a PDO database connection.
private
dbConnect() : PDO
Return values
PDO —isSerialized()
Check if a given string is serialized.
private
isSerialized(string $data) : bool
Parameters
- $data : string
-
The data to check.
Return values
bool —True if the data is serialized, false otherwise.
maybeUnserialize()
Unserialize data if it is serialized.
private
maybeUnserialize(string $data) : mixed
Parameters
- $data : string
-
The data to potentially unserialize.
Return values
mixed —The unserialized data, or the original data if not serialized.