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 | $host | ||
private int | $port | ||
private string | $user | ||
private string | $password | ||
private bool | $connected | ||
private PDO | $link | ||
private array | $myformat | ||
private array | $pgformat |
Methods
Constructor of class Database
Returns the Simulator object that uses this database
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 $simulator, string $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
int
getId()
Returns the ID of this database
at line 228
void
setId(int $id)
Sets the ID of this database
at line 239
string
getType()
Returns the type of this database
at line 251
void
setType(string $type)
Sets the type of this database
at line 262
string
getName()
Returns the name of this database
at line 274
void
setName(string $name)
Sets the name of this database
at line 285
string
getLabel()
Returns the label of this database
at line 297
void
setLabel(string $label)
Sets the label of this database
at line 308
string
getHost()
Returns the host of this database
at line 320
void
setHost(string $host)
Sets the host of this database
at line 331
int
getPort()
Returns the port number of this database
at line 343
void
setPort(int $port)
Sets the port number of this database
at line 354
string
getUser()
Returns the identifier of the user with access rights to this database
at line 366
void
setUser(string $user)
Sets the identifier of the user with access rights to this database
at line 377
string
getPassword()
Returns the password of the user with access rights to this database
at line 389
void
setPassword(string $password)
Sets the password of the user with access rights to this database
at line 400
PDO|JsonSQL
getConnection()
Returns the instance representing a connection to this database
at line 411
bool
isConnected()
Returns the connection status to the database
at line 422
bool
getConnected()
Returns the connection status to the database
at line 434
void
setConnected(bool $connected)
Sets the connection status to the database
at line 446
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 512
array
query(string $sql)
Executes an SQL statement, returning an array containing all of the result set rows
at line 538
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 564
bool
bindParam(PDOStatement $stmt, string|int $parameter, string $variable, string $type = 'text')
Binds a parameter to the specified variable name.
at line 604
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 639
bool
execute(PDOStatement $stmt)
Executes a prepared statement
at line 664
int|bool
exec(string $sql)
Execute an SQL statement and return the number of affected rows
at line 695
string
quote(string $value)
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 714
string
lastInsertId()
Returns the ID of the last inserted row or sequence value
at line 734
private string
convertSQLFunctions(string $sql)
Converts internal functions in a SQL statement into appropriate functions to the database driver