When you run a query with nuRunQuery() and the function returns -1, it means the query was not successful. To retrieve the error details, you can call the nuGetLastError() function. The function returns an object that contains the following properties:
- user: The user who executed the query.
- message: The PDO error message.
- sql: The SQL query that was executed.
- trace: The stack trace for the error.
Here's an example usage:
Code: Select all
$stmt = nuRunQuery('SELECT * FROM table_that_does_not_exist');
if ($stmt === -1) {
$error = nuGetLastError();
nuDisplayError($error->message);
}
Code: Select all
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nubuilder4.table_that_does_not' doesn't exist
- $error->user;
- $error->sql;
- $error->trace;