Kotchasan

Field extends Db
in package

ORM Field base class

Tags
see
https://www.kotchasan.com/

Table of Contents

$table_alias  : string
$table_name  : string
$cfg  : object
Config class instance.
$conn  : string
$db  : Driver
Database connection.
$exists  : bool
$primaryKey  : string
$request  : Request
Server request class instance.
$table  : string
__construct()  : mixed
Class constructor
create()  : static
Create a record
db()  : Driver
Get the database connection.
delete()  : bool
Delete a record
getAllSettings()  : object
Get all database settings.
getConn()  : string
Get the connection name
getFullTableName()  : string
Get the full table name
getPrimarykey()  : string
Get the primary key field name
getSetting()  : mixed
Get the value of a database setting.
getTableName()  : string
Get the table name
getTableWithAlias()  : string
Get the table name with alias
initTableName()  : mixed
Initialize table name and alias
save()  : mixed
Insert or update a record

Properties

$table_alias

public string $table_alias

The table alias

$table_name

public string $table_name

The table name

$cfg

Config class instance.

protected static object $cfg

$conn

protected string $conn = 'mysql'

The connection name used to load the config from settings/database.php

$exists

protected bool $exists

True if the field is queried, false if it is a new item

$primaryKey

protected string $primaryKey = 'id'

The name of the INT(11) AUTO_INCREMENT primary key field

$request

Server request class instance.

protected static Request $request

$table

protected string $table

The table name

Methods

__construct()

Class constructor

public __construct([array<string|int, mixed>|object $param = null ]) : mixed
Parameters
$param : array<string|int, mixed>|object = null

Initial data

Return values
mixed

create()

Create a record

public static create() : static
Return values
static

db()

Get the database connection.

public db() : Driver
Return values
Driver

The database connection.

delete()

Delete a record

public delete() : bool
Return values
bool

True on success, false on failure

getAllSettings()

Get all database settings.

public getAllSettings() : object
Return values
object

The database settings object.

getConn()

Get the connection name

public getConn() : string
Return values
string

The connection name

getFullTableName()

Get the full table name

public getFullTableName(string $table) : string
Parameters
$table : string

The table name specified in settings/database.php

Return values
string

The full table name with prefix, enclosed in backticks (`) if no table name is specified

getPrimarykey()

Get the primary key field name

public getPrimarykey() : string
Return values
string

The primary key field name

getSetting()

Get the value of a database setting.

public getSetting(string $key) : mixed
Parameters
$key : string

The setting key.

Return values
mixed

The value of the setting.

getTableName()

Get the table name

public getTableName() : string
Return values
string

The table name

getTableWithAlias()

Get the table name with alias

public getTableWithAlias([string|null $alias = null ]) : string
Parameters
$alias : string|null = null

The desired alias. If not specified, the defined alias will be used

Return values
string

The table name with the specified alias or the defined alias

initTableName()

Initialize table name and alias

public initTableName(Query $db) : mixed
Parameters
$db : Query

The database query object

Return values
mixed

save()

Insert or update a record

public save() : mixed
Return values
mixed

Search results