PEAR Rocks ( when its done right )
  • Ive never liked the idea of using someone elses framework. Cake, Pear, whatever. Its not my code, and I just dont like that idea. 2 Days ago, I decided to look into PEAR ( how I came here ). I can definitey see how it can get out of hand. But, man, this thing rocks. Especially their database wrapper ( m2bg? or something) . Tis much nicer than the wrapper classes I built..................


    I say, ROCK ON PEAR!
  • In the end, its still working with a mysql database.. So, it will never amount to an oracle day :) but... dude, this rocks.

    require 'MDB2.php';
    $dsn = array(
    'phptype' => 'mysql',
    'username' => 'root',
    'password' => '',
    'hostspec' => 'localhost',
    'database' => 'agroom0_private',
    );
    $mdb2 = &MDB2::connect($dsn);
    if(PEAR::isError($mdb2)) {
    die($mdb2->getuserinfo());
    }
    $projFields = array(
    'id' => array(
    'type' => 'integer',
    'unsigned' => true,
    'autoincrement' => true,
    ),
    'title' => array(
    'type' => 'text',
    'length' => 20
    ),
    'filename' => array(
    'type' => 'text',
    'length' => 155
    ),
    'type' => array(
    'type' => 'text',
    'length' => 5
    ),
    'expires' => array(
    'type' => 'date',
    ),
    );
    $table = "temp_proj_table" . md5(uniqid(1));
    $mdb2->loadModule('Manager', null, true);
    $mdb2->manager->createTable($table, $fields);
  • Just when i thguht binding couldnt get any better....


    $mdb2->prepare(
    $mdb2->buildManipSQL(
    'project',
    array(
    'name','folder',' date_created'
    ),
    MDB2_AUTOQUERY_INSERT)
    );
    $data = array('Dave','text','222');
    $statement->execute($data);
    $statement->free();
  • Yes !
    Pear is more of a modular approach ...not like cake where is all or nothing. On pear you can pick your poison so to speak :)
    I've also developed some pear libs (see http://pear.php.net/user/gurugeek for the full list) some might be useless but it was fun !

    Cheers
    gurugeek
  • see the problem is, i already code in modular approach. so the question is, how do you layer this on top of pear in a good fashion. seems a bit heavy.
  • I've never really been sold the idea of having classes and function and oh noes too much in PHP to cover up SQL queries. Tables are static entities so I've always used PHPMyAdmin to point and click my database design (scribbled on 1-30 pieces of paper...) so your second post seems... pointless (from my perspective...).

    I also can't imagine a complete database wrapper would be able to give you true power over your queries. My database wrapper goes something along the lines of:

    $db = new db;
    $db->sql('query here');
    while($data = $db->data())
    { ... }

    There are other functions but they just mostly mimic mysqli_* stuff and there's some not-really-that-fancy transaction kerfluffle.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook

Share Me

  • Please share this topic with your friends. Click any of the icons below:
  • stumbleupon
  • Twitter
  • facebook
  • myspace
  • technorati
  • reddit
  • fark
  • email