PEAR DB - Useful?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ryan@carsonworkshops.com

    #1

    PEAR DB - Useful?

    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


  • leegold2

    #2
    Re: PEAR DB - Useful?

    ryan@carsonwork shops.com wrote:[color=blue]
    > What are people's thoughts on this class? IMHO, it seems like it's
    > overkill for what most developers need.
    >[/color]

    I started using it then I canned it and returned to the standard PHP. It
    became an issue spending time learning a big class or geting my work
    done. If the documentation was more user oriented-with more everyday
    working examples I could use it maybe. My code was becoming "too
    abstracted" too obtuse. Less maintainable w/the DB class.

    But maybe it's more my own preference or even limitation that I didn't
    use it. I need my code *obvious* above all elese.



    [color=blue]
    > 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
    >[/color]

    Comment

    • Jan Pieter Kunst

      #3
      Re: PEAR DB - Useful?

      ryan@carsonwork shops.com wrote:[color=blue]
      > 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?[/color]

      I use it and like it, even if the part I like is only ..% of its
      functionality. What I like:

      - central error reporting, no "or die()" all over the place

      - nice shortcuts for getting single values or arrays in one pass,
      without looping (getOne(), getCol(), getAssoc())

      - automatic escaping of values with prepared statements:

      $query = 'insert into table (field1, field2) values(?,?)';
      $pear_db_object->query($query , array($raw_data 1, $raw_data2));


      JP


      --
      Sorry, <devnull@cauce. org> is a spam trap.
      Real e-mail address unavailable. 5000+ spams per month.

      Comment

      • kicken

        #4
        Re: PEAR DB - Useful?

        ryan@carsonwork shops.com wrote:[color=blue]
        > 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
        >[/color]

        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($r esult)) 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($r es)){
        throw new DatabaseExcepti on('Unable to query for ...', $res);
        }

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

        if (DB::isError($r es)){
        logWWWError($tp l, new DatabaseExcepti on('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.

        Comment

        • Chung Leong

          #5
          Re: PEAR DB - Useful?

          "ryan@carsonwor kshops.com" <google@carsons ystems.com> wrote in message
          news:1105175181 .455425.137920@ c13g2000cwb.goo glegroups.com.. .[color=blue]
          > What are people's thoughts on this class? IMHO, it seems like it's
          > overkill for what most developers need.[/color]

          Overkill isn't the right word. I would say it just doesn't work that well in
          most situations. Unless your application performs very basic queries, the
          class buys you little in terms of cross platform compatibility, as most
          advanced queries requires vendor specific SQL syntax. This "then it'll work
          with any database!" argument is rather bogus anyway, since few people have
          the resources to actually QA the different setups.



          Comment

          • R. Rajesh Jeba Anbiah

            #6
            Re: PEAR DB - Useful?

            ryan@carsonwork shops.com wrote:[color=blue]
            > What are people's thoughts on this class? IMHO, it seems like it's
            > overkill for what most developers need.[/color]

            I hate PEAR. For database abstraction, I use phpBB like setup.

            --
            <?php echo 'Just another PHP saint'; ?>
            Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

            Comment

            • ryan@carsonworkshops.com

              #7
              Re: PEAR DB - Useful?

              The reason why I asked is because I think the PEAR DB class is a
              classic case of OO over-abstraction. We've noticed a significant gain
              in run-time efficiency by going procedural, instead of using a class to
              connect to the DB. It almost seems backwards, but if it makes the
              application 10% faster, then who's to argue?!

              ----------------------------------------------
              One Day PHP/MySQL Workshop


              Comment

              Working...