PEAR extensions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    PEAR extensions

    Hi,

    I've just recently starting getting into and learning PEAR, but one thing I haven't come accross yet is using PEAR to insert data into a DB... can it be used for this? and also what are your views on it's cache function?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    PEAR itself does not help you in programming, it's a tool to provide you with additional PHP software (functions, classes, etc.).

    although there are PEAR modules, that can do DB handling (MDB2*), PHP has powerful DB handlers itself (PDO and (esp. for MySQL) MySQLi)

    * - last time I was trying MDB2, it was written for PHP 4 (compatible), which constantly threw E_STRICTs

    Comment

    • anfetienne
      Contributor
      • Feb 2009
      • 424

      #3
      can i intergrate PDO & PEAR cache... my aim is to abstract data from a db as fast and as clean as possible but cache certain sql queries so getting the data is faster and uses less memory in the db server

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        … cache certain sql queries …
        that’s what Prepared Statements do.

        the PDO-Guy

        Comment

        • anfetienne
          Contributor
          • Feb 2009
          • 424

          #5
          ok last question can i use pdo for db abstraction as well just like pear db does? if i can use both then that would be perfect

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            PDO *is* Database Abstraction.

            Comment

            • anfetienne
              Contributor
              • Feb 2009
              • 424

              #7
              ok i've done a few tests selecting and inserting data using both pear and pdo... they are practically the same and work just as fast as each other... only difference for me is pdo doesn't need the require_once statement as pear does to include functions and classes to work with.

              but pear has a cache function, i've looked everywhere for a cache function pdo uses or even how to use it with query_cache... can you point me in the right direction?

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                does query_cache is supported by all databases, that are supported by PDO?

                Comment

                • anfetienne
                  Contributor
                  • Feb 2009
                  • 424

                  #9
                  sorry this page went blank and when i refreshed it came back with to posts

                  Comment

                  • anfetienne
                    Contributor
                    • Feb 2009
                    • 424

                    #10
                    from what i have read mysql db has a query_cache function that once you switch it on everything is cached incase of repeat queries. if a query is repeated it will go to the cache before it processes anything and if it exists it will run from the cache and save memory and time. ive read forums and blogs to see if pdo has its own cache or is useable with query_cache but all i've seen is people in the same boat as me

                    Comment

                    • Dormilich
                      Recognized Expert Expert
                      • Aug 2008
                      • 8694

                      #11
                      PDO is intended to use different DBs, if only MySQL and PGSQL have that cache option, I doubt the PHP developers would put that in.

                      but actually, I can’t imagine a scenario, where you would profit from the query_cache, I prefer to break it down and use Prepared Statements (because I’m too lazy to escape the input)

                      Comment

                      • anfetienne
                        Contributor
                        • Feb 2009
                        • 424

                        #12
                        ok so prepared statements work exactly the same way as a cache and does hog so much memory and time on a db server? if that's so then i guess it's the best and most simplest thing to do and use

                        Comment

                        • Dormilich
                          Recognized Expert Expert
                          • Aug 2008
                          • 8694

                          #13
                          ok so prepared statements work exactly the same way as a cache and does hog so much memory and time on a db server?
                          no. Prepared Statements are a kind of SQL template that is saved on the database. once that is done, you only transfer data*.

                          * - and it’s incredibly safe against SQL Injection.

                          Comment

                          • anfetienne
                            Contributor
                            • Feb 2009
                            • 424

                            #14
                            sorry... *doesn't

                            Comment

                            • anfetienne
                              Contributor
                              • Feb 2009
                              • 424

                              #15
                              ok, i understand pdo and now prepared statements... now for the last question... with PDO and preapred statements is there any need to cache the queries?

                              Comment

                              Working...