Re: New Bie DB_ldap help

From: Date: Mon, 10 Oct 2005 09:17:16 +0000
Subject: Re: New Bie DB_ldap help
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21311@lists.php.net to get a copy of this message
On 10/8/05, Justin Patrin <papercrane@gmail.com> wrote: > On 10/8/05, Ramdas Phutane <ramdas.phutane@gmail.com> wrote: > > Hi Group, > > > > I am want some help with DB_ldap. > > > > I want to do a ldap_connect -> ldap_search -> print result using > > DB_ldap. But I am not able to get any example code for this. > > > > Could any one please help me. > > > > My code (not working ) > > -------------- > > <? > > require_once ('DB/ldap.php') ; > > require_once 'DB/common.php'; > > You shouldn't ever need to include DB/common.php. In fact you never > need to include any DB/* files. Just: > require_once('DB.php'); > > > > > $params = array ( > > 'username' => 'cn=root,c=IN' , > > 'password' => 'pass', > > 'hostspec' => 'localhost', > > 'database' => 'c=IN' > > ) ; > > > > $db = new DB_ldap ; > > # To Connect > > $db->connect($params) ; > > Don't do it that way. > $db =& DB::connect($params); > > > if (PEAR::isError($db)) { > > die($db->getMessage()); > > } > > # To perform query > > $res = $db->simpleQuery('cn=man*','search',$params) ; > > $res1 = $db->query('cn=man*','search',$params) ; > > Why are you querying twice? Only use query(), not simpleQuery(). > > > # RND, I am not sure how to display results > > echo $res ; > > var_dump ($res1) ; > > echo '<br>'; > > echo $res1 ; > > query() returns a result. You don't want to output that. > > > > > echo '<br>'; > > $result = $db->getRow($res1) ; > > echo $result ; > > echo 'Hello<br>' ; > > ?> > > You need to read the DB manual. > while ($row = $res1->fetchRow()) { //you may want DB_FETCHMODE_ASSOC > print_r($row); > } > > > -- > Justin Patrin > Sorry For delayed reply And Thanx It works. But still I wonder does anyone use DB_ldap2 class for ldap query. And if yes then how to go about it. (any example code will be of help) Also I am studying the DB Manual. Thanx and Regards RamDas Phutane

« previous php.pear.general (#21311) next »