[TYPO3-core] RFC: another enhancement to the DB connect method and error display in the FE
Martin Kutschker
martin.kutschker-n0spam at no5pam-blackbox.net
Tue Sep 25 10:50:53 CEST 2007
Dmitry Dulepov [typo3] schrieb:
>
> t3lib_db is a class. So I think we should have a method there for
> returning errors. Something like getLastErrorCode() and getLastError().
> Having default parameters to functions for returning values in not very
> OO approach. What do you think?
>
> So code will look like:
>
> if (!$TYPO3_db->p_connect($TYPO3_db_host, $TYPO3_db_username,
> $TYPO3_db_password)) {
> $lastError = $TYPO3_db->getLastError();
> // TODO Show nice error
> }
Personally I don't like the get_lats_whatever() approach not very much.
I'm much more in favour of a return object/array style where the results
and status code etc are in properties. Of course this can't be done here
because of compatibiliyt. Which is the *only* reason the parameter is
optional.
And I think it's up to the caller to format the message nicely. A (low
level) call should only return a simple string.
But for me is more important that the user gets the info directly. If
the majority likes your idea better, fine with me.
> It also reminds me about idea of standalone system function (in
> t3lib_div?) that can format and output such critical errors generally in
> typo3 because right now everyone does it on its own: core shows its
> errors in one style, realurl in another, templavoila has yet its own
> box. We should have a template file that can be used for that (and
> changable by admin).
Nice idea.
Masi
More information about the TYPO3-team-core
mailing list