매뉴얼

Rhymix\Framework\DB

getInstance() #

public static function getInstance(string $type = 'master'): self

Get a singleton instance of the DB class.

__construct() #

public function __construct(
    string $type,
    array $config
)

Constructor.

connect() #

public function connect(array $config): void

Connect to the database.

disconnect() #

public function disconnect(): void

Disconnect from the database.

getHandle() #

public function getHandle(): ?Rhymix\Framework\Helpers\DBHelper

Get the PDO handle for direct manipulation.

prepare() #

public function prepare(
    string $statement,
    array $driver_options = []
): Rhymix\Framework\Helpers\DBStmtHelper

Create a prepared statement. Table names in the FROM or JOIN clause of the statement are automatically prefixed with the configured prefix. Note that this method will throw an exception (DBError) on error, instead of returning false or null as legacy functions do.

query() #

public function query(
    string $query_string,
    $args
): ?Rhymix\Framework\Helpers\DBStmtHelper

Execute a query string with or without parameters. This method will automatically use prepared statements if there are any parameters. It is strongly recommended to pass any user-supplied values as separate parameters instead of embedding them directly in the query string, in order to prevent SQL injection attacks. Table names in the FROM or JOIN clause of the statement are automatically prefixed with the configured prefix.

executeQuery() #

public function executeQuery(
    string $query_id,
    $args = [],
    array $column_list = [],
    string $result_type = 'auto',
    string $result_class = ''
): Rhymix\Framework\Helpers\DBResultHelper

Execute an XML-defined query.

fetch() #

public function fetch(
    $stmt,
    int $last_index = 0,
    string $result_type = 'auto',
    string $result_class = ''
)

Fetch results from a query.

beginTransaction() #

public function beginTransaction(): int

Alias to begin().

begin() #

public function begin(): int

Begin a transaction.

rollback() #

public function rollback(): int

Roll back a transaction.

commit() #

public function commit(): int

Commit a transaction.

getTransactionLevel() #

public function getTransactionLevel(): int

Get the current transaction level.

getAffectedRows() #

public function getAffectedRows(): int

Get the number of rows affected by the last statement.

getInsertID() #

public function getInsertID(): int

Get the auto-incremented ID generated by the last statement.

getNextSequence() #

public function getNextSequence(): int

Get the next global sequence value.

isValidOldPassword() #

public function isValidOldPassword(
    string $password,
    string $saved_password
): bool

Check if a password is valid according to MySQL's old password hashing algorithm.

isTableExists() #

public function isTableExists(string $table_name): bool

Check if a table exists.

createTable() #

public function createTable(
    string $filename = '',
    string $content = ''
): Rhymix\Framework\Helpers\DBResultHelper

Create a table.

dropTable() #

public function dropTable(string $table_name): Rhymix\Framework\Helpers\DBResultHelper

Drop a table.

isColumnExists() #

public function isColumnExists(
    string $table_name,
    string $column_name
): bool

Check if a column exists.

addColumn() #

public function addColumn(
    string $table_name,
    string $column_name,
    string $type = 'number',
    $size = null,
    $default = null,
    $notnull = false,
    $after_column = null
): Rhymix\Framework\Helpers\DBResultHelper

Add a column.

modifyColumn() #

public function modifyColumn(
    string $table_name,
    string $column_name,
    string $type = 'number',
    $size = null,
    $default = null,
    $notnull = false,
    $after_column = null,
    $new_name = null,
    $new_charset = null
): Rhymix\Framework\Helpers\DBResultHelper

Modify a column.

dropColumn() #

public function dropColumn(
    string $table_name,
    string $column_name
): Rhymix\Framework\Helpers\DBResultHelper

Drop a column.

getColumnInfo() #

public function getColumnInfo(
    string $table_name,
    string $column_name
): ?object

Get column information.

isIndexExists() #

public function isIndexExists(
    string $table_name,
    string $index_name
): bool

Check if an index exists.

addIndex() #

public function addIndex(
    string $table_name,
    string $index_name,
    $columns,
    $type = '',
    $options = ''
): Rhymix\Framework\Helpers\DBResultHelper

Add an index.

dropIndex() #

public function dropIndex(
    string $table_name,
    string $index_name
): Rhymix\Framework\Helpers\DBResultHelper

Drop an index.

getIndexInfo() #

public function getIndexInfo(
    string $table_name,
    string $index_name
): ?object

Get index information.

addPrefixes() #

public function addPrefixes(string $query_string): string

Add table prefixes to a query string.

addQuotes() #

public function addQuotes($str): string

Escape a string according to current DB settings.

getBestSupportedCharset() #

public function getBestSupportedCharset(): string

Find out the best supported character set.

isError() #

public function isError(): bool

Check if the last statement produced an error.

getError() #

public function getError(): Rhymix\Framework\Helpers\DBResultHelper

Get the last error information.

setError() #

public function setError(
    int $errno = 0,
    string $errstr = 'success'
): Rhymix\Framework\Helpers\DBResultHelper

Set error information to instance properties.

clearError() #

public function clearError(): void

Clear error information.

getQueryLog() #

public function getQueryLog(
    string $query,
    float $elapsed_time
): array

Generate a query log entry.

setQueryLog() #

public function setQueryLog(array $log): void

Send an entry to the query log for debugging.

addElapsedTime() #

public function addElapsedTime(float $elapsed_time): void

Add elapsed time.

getQueryElapsedTime() #

public function getQueryElapsedTime(): float

Get total time spent during queries.

getTotalElapsedTime() #

public function getTotalElapsedTime(): float

Get total time spent in this class.

setDebugComment() #

public function setDebugComment(bool $enabled): void

Enable or disable debug comments.

__get() #

public function __get(string $key)

Magic method to support some read-only properties for backward compatibility.

_query() #

public function _query($query_string): ?Rhymix\Framework\Helpers\DBStmtHelper

Execute a literal query string. Use query() instead, or call methods directly on the handle.

_fetch() #

public function _fetch(
    $stmt,
    int $last_index = 0
)

Fetch results from a query. Use query() and fetch() instead.

create() #

public static function create(): self

Old alias to getInstance().

db_fetch_object() #

public function db_fetch_object(PDOStatement $stmt)

Old alias to $stmt->fetchObject().

db_free_result() #

public function db_free_result(PDOStatement $stmt): bool

Old alias to $stmt->closeCursor().

db_insert_id() #

public function db_insert_id(): int

Old alias to getInsertID().

getSupportedList() #

public static function getSupportedList(): array

Get the list of supported database drivers.

getEnableList() #

public static function getEnableList(): array

Get the list of enabled database drivers.

getDisableList() #

public static function getDisableList(): array

Get the list of disabled database drivers.

isSupported() #

public function isSupported(): bool

Check if the current instance is supported.

isConnected() #

public function isConnected(): bool

Check if the current instance is connected.

close() #

public function close(): bool

Close the DB connection.

createTableByXmlFile() #

public function createTableByXmlFile($filename): bool

Methods related to table creation.

createTableByXml() #

public function createTableByXml($xml_doc)

_createTable() #

public function _createTable($xml_doc)

getCountCache() #

public function getCountCache(): bool

Methods related to the click count cache feature.

putCountCache() #

public function putCountCache(): bool

resetCountCache() #

public function resetCountCache(): bool

getParser() #

public function getParser(): bool

Other deprecated methods.

_getSlaveConnectionStringIndex() #

public function _getSlaveConnectionStringIndex(): int

_getConnection() #

public function _getConnection(): ?Rhymix\Framework\Helpers\DBHelper

_dbInfoExists() #

public function _dbInfoExists(): bool

매뉴얼 홈

개요

확장 기능 제작

테마 제작

클래스 및 함수 명세

코어 개발 참여

기타 정보