Database
class Database
this class provides a unified access interface to SQL databases, whether MySQL, PostgreSQL, SQLite, or JsonSQL
Properties
private Simulator | $simulator | ||
private string | $databasesDir | ||
private int | $id | ||
private string | $type | ||
private string | $name | ||
private string | $label | ||
private string|null | $host | ||
private int | $port | ||
private string|null | $user | ||
private string|null | $password | ||
private bool | $connected | ||
private PDO|JsonSQL | $link | ||
private array | $myformat | ||
private array | $pgformat |
Methods
Constructor of class Database
Returns the Simulator object that uses this database
Returns the database directory
Returns the ID of this database
Sets the ID of this database
Returns the type of this database
Sets the type of this database
Returns the name of this database
Sets the name of this database
Returns the label of this database
Sets the label of this database
Returns the host of this database
Sets the host of this database
Returns the port number of this database
Sets the port number of this database
Returns the identifier of the user with access rights to this database
Sets the identifier of the user with access rights to this database
Returns the password of the user with access rights to this database
Sets the password of the user with access rights to this database
Returns the instance representing a connection to this database
Returns the connection status to the database
Returns the connection status to the database
Sets the connection status to the database
Composes a DSN (Data Source Name) string, connects to the database and stores an instance representing a connection to a database
Executes an SQL statement, returning an array containing all of the result set rows
Prepares a statement for execution and returns a statement object.
Binds a parameter to the specified variable name.
Binds a value to a parameter
Execute an SQL statement and return the number of affected rows
Quotes a string for use in a query.
Returns the ID of the last inserted row or sequence value
Converts internal functions in a SQL statement into appropriate functions to the database driver
Details
at line 190
void
__construct(Simulator|null $simulator, string|null $databasesDir, int $id, string $type, string $name)
Constructor of class Database
at line 205
Simulator
getSimulator()
Returns the Simulator object that uses this database
at line 216
string|null
getDatabasesDir()
Returns the database directory
at line 227
int
getId()
Returns the ID of this database
at line 239
void
setId(int $id)
Sets the ID of this database
at line 250
string
getType()
Returns the type of this database
at line 262
void
setType(string $type)
Sets the type of this database
at line 273
string
getName()
Returns the name of this database
at line 285
void
setName(string $name)
Sets the name of this database
at line 296
string
getLabel()
Returns the label of this database
at line 308
void
setLabel(string $label)
Sets the label of this database
at line 319
string|null
getHost()
Returns the host of this database
at line 331
void
setHost(string|null $host)
Sets the host of this database
at line 342
int
getPort()
Returns the port number of this database
at line 354
void
setPort(int $port)
Sets the port number of this database
at line 365
string|null
getUser()
Returns the identifier of the user with access rights to this database
at line 377
void
setUser(string|null $user)
Sets the identifier of the user with access rights to this database
at line 388
string|null
getPassword()
Returns the password of the user with access rights to this database
at line 400
void
setPassword(string|null $password)
Sets the password of the user with access rights to this database
at line 411
PDO|JsonSQL
getConnection()
Returns the instance representing a connection to this database
at line 422
bool
isConnected()
Returns the connection status to the database
at line 433
bool
getConnected()
Returns the connection status to the database
at line 445
void
setConnected(bool $connected)
Sets the connection status to the database
at line 457
bool
connect(bool $withDbName = true)
Composes a DSN (Data Source Name) string, connects to the database and stores an instance representing a connection to a database
at line 523
array|string|bool
query(string $sql)
Executes an SQL statement, returning an array containing all of the result set rows
at line 549
PDOStatement|Statement
prepare(string $sql)
Prepares a statement for execution and returns a statement object.
The SQL statement can contain zero or more named (:name) or question mark (?) parameter markers for which real values will be substituted when the statement is executed.
at line 575
bool
bindParam(PDOStatement $stmt, string|int $parameter, string $variable, string $type = 'text')
Binds a parameter to the specified variable name.
at line 615
bool
bindValue(PDOStatement $stmt, string|int $parameter, string $value, string $type = 'text')
Binds a value to a parameter
Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement.
at line 650
array|string|bool
execute(PDOStatement $stmt)
Executes a prepared statement
at line 675
int|bool
exec(string $sql)
Execute an SQL statement and return the number of affected rows
at line 707
string
quote(string $value, int $type = \PDO::PARAM_STR)
Quotes a string for use in a query.
Places quotes around the input string (if required) and escapes special characters within the input string, using a quoting style appropriate to the underlying driver.
at line 726
string
lastInsertId()
Returns the ID of the last inserted row or sequence value
at line 746
private string
convertSQLFunctions(string $sql)
Converts internal functions in a SQL statement into appropriate functions to the database driver