Re: new package DB_Abstract/Easy/DataBuilder/DataGette r/?

From: Date: Tue, 14 Jan 2003 14:54:42 +0000
Subject: Re: new package DB_Abstract/Easy/DataBuilder/DataGette r/?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12407@lists.php.net to get a copy of this message
a nice name would be appreciated :-) LIMBOURG Arnaud wrote:
Looks good to me ! +1 for about almost a year now we are continuosly improving our package, which we decided to contribute to pear now. the package itself is based on PEAR::DB (optional MDB, would be minor change) and it is a bit like the DB_DataObject - only that the data are not really inside objects and - that the query-building is more flexible, i believe. - actually it is a query-builder and executer ... we are building our applications always with this class and since then (i dont remember that) we have written a single SQL-Query by hand, so it seems quite flexible currently the class name is vp_DB, i thought it might be named DB_Abstract/Easy/DataBuilder/DataGetter/???? (even though i think better names could be found) the class is capable of, manipulating the entire query incl - where - joins, left and right joins - group - order and many more things methods are: get, getAll, getMultiple, update, save, add, remove, getCount, setWhere, addWhere, getWhere, setJoin, addJoin, setLeftJoin, addLeftJoin, setGroup, getGroup, setOrder, getOrder, setIndex, getIndex, setSelect, getSelect and some more i guess ... short examples might demostrate some of what it does
          require_once 'vp/DB.php';
          class contact extends vp_DB {
                      var $table = 'contact';
              var $primaryCol = 'id';
              }
              $contact = new contact();
      (1)
      // get the contact with the id=7
              $data = $contact->get(7);
      (2)
      // reset all internal settings
      $contact->reset();
              $contact->setWhere('name="Wolfram"');
      $contact->setOrder('name');
      // get the first 10 (LIMIT 0,10)
      $contacts = $contact->getAll(0,10);
      (3)
      // reset all internal settings
      $contact->reset();
              $contact->addWhereSearch('name','Wolfram Kriesing');
      $contacts = $contact->getAll(0,10);
      (4)
      // reset all internal settings
      $contact->reset();
              $contact->addWhereSearch('name','Wolfram Kriesing');
      // select only the columns 'name' and 'surname'
      $contact->setSelect('name,surname');
      $contact->setGroup('name'); // group by 'name'
      // the number of contacts
      $numContacts = $contact->getCount();
      $contacts = $contact->getAll(0,10);
      JOINS
      (5)
      // join the table 'user'
      // using the condition 'user.id=contact.user_id'
      $contact->reset();
      $contact->setJoin('user','user.id=contact.user_id');
      $contacts = $contact->getAll(0,10);
      (6)
      // the same as above, just that the class
      // knows itself how to join the tables,
      // by using a regular expression
      $contact->reset();
      $contact->autoJoin('user');
      $contacts = $contact->getAll(0,10);
the queries would be: (1) SELECT * FROM contact WHERE id=7 (2) SELECT * FROM contact WHERE name="Wolfram" LIMIT 0,10 (3) SELECT * FROM contact WHERE name LIKE "%Wolfram%Kriesing%" LIMIT 0,10 (4) getCount: SELECT count(*) FROM contact WHERE name LIKE "%Wolfram%Kriesing%" GROUP BY name LIMIT 0,10 getAll: SELECT name,surname FROM contact WHERE name LIKE "%Wolfram%Kriesing%" GROUP BY name LIMIT 0,10 (5) (6) SELECT * FROM contact,user WHERE user.id=contact.user_id code is here, needs minor modification before it goes into pear http://os.visionp.de/tmp/vp_DB/Common.php.txt -- Wolfram ... opensource @ vision:produktion ...
         http://opensource.visionp.de
... translating template engine ....
        http://sf.net/projects/simpletpl
... authentication system ....
        http://sf.net/projects/auth
-- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Wolfram ... opensource @ vision:produktion ... http://opensource.visionp.de ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth

« previous php.pear.dev (#12407) next »