PHP mysqli_sql_exception class
PHP mysqli_sql_exception is the class that manages exceptions within the mysqli extension.
final class mysqli_sql_exception extends RuntimeException {
/* Properties */
protected string $sqlstate = "00000";
/* Inherited properties */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private ?Throwable $previous = null;
/* Methods */
public getSqlState(): string
/* Inherited methods */
final public Exception::getMessage(): string
final public Exception::getPrevious(): ?Throwable
final public Exception::getCode(): int
final public Exception::getFile(): string
final public Exception::getLine(): int
final public Exception::getTrace(): array
final public Exception::getTraceAsString(): string
public Exception::__toString(): string
private Exception::__clone(): void
}
Properties
https://blastcoding.com/php-mysqli_sql_exception/#propiedades$sqlstate – SQLSTATE error code.
$message – the message of the exception (inherited from Exception).
$string – The string representation of the stack trace (inherited from Exception).
$code – the exception code (inherited from Exception).
$file – the name of the file where the exception was created (inherited from Exception).
$line – Line where the exception was created (inherited from Exception).
$trace – The stack trace as an array (inherited from Exception).
$previous – The previous exception thrown (inherited from Exception).
Methods
https://blastcoding.com/php-mysqli_sql_exception/#metodosThe following methods were created to be able to obtain the values of the previously mentioned properties; keep in mind that at the time the class was created, readonly could not be used directly on the property.
getSqlState()
https://blastcoding.com/php-mysqli_sql_exception/#getSqlStateReturns a string containing the SQLSTATE error code for the last error. This code consists of 5 characters.
http://dev.mysql.com/doc/mysql/en/error-handling.html.
Description / Descripciónpublic mysqli_sql_exception::getSqlState(): string
getMessage()
https://blastcoding.com/php-mysqli_sql_exception/#getMessageGets the exception message as a string; this method is inherited from the Exception class.
final public Exception::getMessage(): string
getCode()
https://blastcoding.com/php-mysqli_sql_exception/#getCodeThe exception code obtained from $code; this method is inherited from the Exception class.
final public Exception::getCode(): int
getFile()
https://blastcoding.com/php-mysqli_sql_exception/#getFileIt will return the file where the exception was created as a string; this method is inherited from the Exception class.
final public Exception::getFile(): string
getLine()
https://blastcoding.com/php-mysqli_sql_exception/#getLineReturns the line where the exception was created; this method is inherited from the Exception class.
final public Exception::getLine(): int
getTrace()
https://blastcoding.com/php-mysqli_sql_exception/#getTraceGets the stack trace; this method is inherited from the Exception class.
final public Exception::getTrace(): array
In the returned associative array, you can see the following values: file, line, function, args, class, object.
getTraceAsString()
https://blastcoding.com/php-mysqli_sql_exception/#getTraceAsStringGets the stack trace as a string, this method is inherited from the Exception class
final public Exception::getTraceAsString(): string

