Whats the best/preferred way of getting error info strings back from xPDO. I’m looking for an equivalent of the MYSQL function ’mysql_error’ so I can feed this back to the GUI. A bit of context, I’m calling the save() function on an element(template actually) that’s failing, the fail is ’template with that name already exists’ i.e. duplicate, this is OK, I just want to tell the user.
Use MODx, or the cat gets it!
Ok, using this snippet of code :-
if ($element->save() == false) {
$errorText = $element->xpdo->errorInfo();
$errorstring = $errorText[0];
$errorstring .= " : " . $errorText[1];
$errorstring .= " : " . $errorText[2];
I get this output ’00000 : : ’, this may be because of this from PHP :-
PDO::errorInfo() only retrieves error information for operations performed directly on the database handle. If you create a PDOStatement object through PDO::prepare() or PDO::query() and invoke an error on the statement handle, PDO::errorInfo() will not reflect the error from the statement handle. You must call PDOStatement::errorInfo() to return the error information for an operation performed on a particular statement handle.
If so I’ll file a bug, it would be handy to be able to do this.
Use MODx, or the cat gets it!