|
static | testConnectivity (string $type, string $user=null, string $pass=null, string $host=null, string $port=null, string $db=null) |
|
|
const | MYSQL = 'mysql' |
|
const | PGSQL = 'pgsql' |
|
const | MYSQL_DEFAULT_PORT = 3306 |
|
const | PGSQL_DEFAULT_PORT = 5432 |
|
◆ __construct()
Galette\Core\Db::__construct |
( |
array |
$dsn = null | ) |
|
Main constructor
- Parameters
-
?array<string,string> | $dsn Connection information If not set, database constants will be used. |
- Exceptions
-
◆ __get()
Galette\Core\Db::__get |
( |
string |
$name | ) |
|
Global getter method
- Parameters
-
string | $name | name of the variable we want to retrieve |
- Returns
- mixed
- Exceptions
-
◆ __isset()
Galette\Core\Db::__isset |
( |
string |
$name | ) |
|
Global isset method Required for twig to access properties via __get
- Parameters
-
string | $name | name of the variable we want to retrieve |
- Returns
- bool
◆ __sleep()
Galette\Core\Db::__sleep |
( |
| ) |
|
To store Db in session
- Returns
- array
◆ __wakeup()
Galette\Core\Db::__wakeup |
( |
| ) |
|
Connect again to the database on wakeup
- Returns
- void
◆ checkDbVersion()
Galette\Core\Db::checkDbVersion |
( |
| ) |
|
Check if database version suits our needs
- Returns
- boolean
◆ convertToUTF()
Galette\Core\Db::convertToUTF |
( |
string |
$prefix = null , |
|
|
bool |
$content_only = false |
|
) |
| |
Converts recursively database to UTF-8
- Parameters
-
| ?string | $prefix Specified table prefix |
boolean | $content_only | Proceed only content (no table conversion) |
- Returns
- void
◆ delete()
Galette\Core\Db::delete |
( |
string |
$table | ) |
|
Instanciate a delete query
- Parameters
-
string | $table | Table name, without prefix |
- Returns
- Delete
◆ drop()
Galette\Core\Db::drop |
( |
string |
$table, |
|
|
bool |
$maymiss = false |
|
) |
| |
Drops a table
- Parameters
-
string | $table | Table name, without prefix |
boolean | $maymiss | Whether the table can be missing, defaults to false |
- Returns
- void
◆ dropTestTable()
Galette\Core\Db::dropTestTable |
( |
| ) |
|
Drop test table if it exists, so we can make all checks.
- Returns
- void
◆ execute()
Galette\Core\Db::execute |
( |
SqlInterface |
$sql | ) |
|
Execute query string
- Parameters
-
SqlInterface | $sql | SQL object |
- Returns
- ResultSet|Result
- Exceptions
-
◆ getColumns()
Galette\Core\Db::getColumns |
( |
string |
$table | ) |
|
Get columns for a specified table
- Parameters
-
- Returns
- array<int, ColumnObject>
◆ getDbVersion()
Galette\Core\Db::getDbVersion |
( |
bool |
$check_table = false | ) |
|
Retrieve current database version
- Parameters
-
boolean | $check_table | Check if table exists, defaults to false |
- Returns
- string
- Exceptions
-
◆ getInfos()
Galette\Core\Db::getInfos |
( |
| ) |
|
Get database information
- Returns
- array<string, string>
◆ getLastGeneratedValue()
Galette\Core\Db::getLastGeneratedValue |
( |
object |
$entity | ) |
|
Get last generated value
- Parameters
-
object | $entity | Entity instance |
- Returns
- integer
@phpstan-ignore-next-line
◆ getTables()
Galette\Core\Db::getTables |
( |
string |
$prefix = null | ) |
|
Get a list of Galette's tables
- Parameters
-
?string | $prefix Specified table prefix, PREFIX_DB if null |
- Returns
- array<int, string>
◆ getUnsupportedMessage()
Galette\Core\Db::getUnsupportedMessage |
( |
| ) |
|
Get not supported database version message
- Returns
- string
◆ getWarnings()
Galette\Core\Db::getWarnings |
( |
| ) |
|
Get MySQL warnings
- Returns
- array<array<string, string>>
◆ grantCheck()
Galette\Core\Db::grantCheck |
( |
string |
$mode = 'i' | ) |
|
Checks GRANT access for install time
- Parameters
-
string | $mode | are we at install time (i) or update time (u) ? |
- Returns
- array<string, bool|Throwable> containing each test. Each array entry could be either true or contains an exception or false if test did not run.
◆ handleSequence()
Galette\Core\Db::handleSequence |
( |
string |
$table, |
|
|
int |
$expected |
|
) |
| |
◆ insert()
Galette\Core\Db::insert |
( |
string |
$table | ) |
|
Instanciate an insert query
- Parameters
-
string | $table | Table name, without prefix |
- Returns
- Insert
◆ isDuplicateException()
Galette\Core\Db::isDuplicateException |
( |
SqlInterface |
$sql, |
|
|
Throwable |
$exception |
|
) |
| |
Check if current exception is on a duplicate key
- Parameters
-
SqlInterface | $sql | SQL object |
Throwable | $exception | Exception to check |
- Returns
- boolean
◆ isEngineSUpported()
Galette\Core\Db::isEngineSUpported |
( |
| ) |
|
Is current database engine supported?
- Returns
- bool
◆ isForeignKeyException()
Galette\Core\Db::isForeignKeyException |
( |
Throwable |
$exception | ) |
|
Check if current exception is related to a remaining foreign key
- Parameters
-
Throwable | $exception | Exception to check |
- Returns
- boolean
◆ isPostgres()
Galette\Core\Db::isPostgres |
( |
| ) |
|
Is current database using Postgresql?
- Returns
- boolean
◆ log()
Galette\Core\Db::log |
( |
string |
$query | ) |
|
|
protected |
Log queries in specific file
- Parameters
-
string | $query | Query to add in logs |
- Returns
- void
◆ select()
Galette\Core\Db::select |
( |
string |
$table, |
|
|
string |
$alias = null |
|
) |
| |
Instanciate a select query
- Parameters
-
string | $table | Table name, without prefix |
| ?string | $alias Tables alias, optional |
- Returns
- Select
◆ selectAll()
Galette\Core\Db::selectAll |
( |
string |
$table | ) |
|
Peform a select query on the whole table
- Parameters
-
- Returns
- ResultSet
◆ testConnectivity()
static Galette\Core\Db::testConnectivity |
( |
string |
$type, |
|
|
string |
$user = null , |
|
|
string |
$pass = null , |
|
|
string |
$host = null , |
|
|
string |
$port = null , |
|
|
string |
$db = null |
|
) |
| |
|
static |
Test if database can be contacted. Mostly used for installation
- Parameters
-
string | $type | db type |
| ?string | $user database's user |
| ?string | $pass password for the user |
| ?string | $host which host we want to connect to |
| ?string | $port which tcp port we want to connect to |
| ?string | $db database name |
- Returns
- boolean
- Exceptions
-
◆ update()
Galette\Core\Db::update |
( |
string |
$table | ) |
|
Instanciate an update query
- Parameters
-
string | $table | Table name, without prefix |
- Returns
- Update
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/galette-apidoc/checkouts/develop/galette/lib/Galette/Core/Db.php