Re: PEAR DB - Useful?

From: kicken (slick_at_aoeex.com)
Date: 01/08/05


Date: Sat, 08 Jan 2005 05:22:11 -0700

ryan@carsonworkshops.com wrote:
> What are people's thoughts on this class? IMHO, it seems like it's
> overkill for what most developers need.
>
> I've been using it for awhile now, and I tend to use only about 3% of
> it's functionality.
>
> Thoughts? Opinions?
> -----------------
> One Day PHP/MySQL Workshop
> www.carsonworkshops.com
>

        I use it and like it quite well. I also only use probably only a small
amount, but I find it makes things much more manageable and a bit easier
to read/understand. I like the fact that provided I produce complient
SQL, all I have to do is change the connect string and I can use it to
work with more or less any database out there. Personally I only use
mysql, but for projects I make which I distribute, like my IRC bot, I
can say that it can, theoretically, be used with databases other than mysql.

        I also like the if (DB::isError($result)) part, as it makes error
checking eaiser. Now I don't have to worry about 'for this sql
statement, what constitues an error' type things. Coupling that with
PHP5's exceptions and stuff, I do things like this:

if (DB::isError($res)){
        throw new DatabaseException('Unable to query for ...', $res);
}

then my DatabaseException class can examine the $res varible and provide
debugging information in a log file. Again couple these exceptions with
templates(smarty) and a logError function, I can do things like this:

if (DB::isError($res)){
        logWWWError($tpl, new DatabaseException('Unable to query for ...',
$res), __FILE__, __LINE__);
        exit;
}

and not only do I get quick error checking, but I get a nice log file
with sql error details and also a generated error page which is shown to
the user with the message from the exception. Makes my applications
look nicer, and run a bit smoother I think.



Relevant Pages

  • Re: PerfMon recording to SQL 2005
    ... seconds or even every ne second) from a busy server to a database on ... On the Perfmon counter Log Files tab, SQL Database has been set, End File ... Configuring the log file, choose the tested DSN as the System DSN ... The user account I created in SQL is an owner of the ...
    (microsoft.public.sqlserver.server)
  • Re: Detached database cant be attached back
    ... Are you saying that you deleted one of the log files, and then copied the second log file to the ... Tibor Karaszi, SQL Server MVP ... Original database had 2 datafiles and 2 log files. ... Could not open new darabase 'crn'. ...
    (microsoft.public.sqlserver.server)
  • cancelled at the users request
    ... I'm writng a servlet to maintain a database of users. ... During a run of getting the exceptions ... I tried doing the sql as separate executes rather than batch ... boolean communityExists = false; ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: How to manage the transaction log
    ... Just remember to backup the database before the BCP ... I am using the SQL Server 2005 Express. ... I set the Autogrowth of log file unrestricted. ...
    (microsoft.public.sqlserver.tools)
  • Re: How to manage the transaction log
    ... As I mentioned in my previous post, the issue is even if I set the log file ... am still new to SQL Server. ... I created the database with "Simple" Recover Model. ... Just remember to backup the database before the BCP ...
    (microsoft.public.sqlserver.tools)