TomT Posted October 3, 2011 Share Posted October 3, 2011 Hi I'm using a couple of queries to search a database. This works well but is slow as I'm cascading/nesting the queries.. Below is an example of what I mean... (LDAP queries) Code: <? $dn = "cn=user"; $filter="(objectclass=user)"; $justthese = array('cn','telephone','guid','ID','email'); $sr=ldap_search($ds, $dn, $filter, $justthese); $info = ldap_get_entries($ds, $sr); for ($n=0; $n<$info['count']; $n++) { $cn = $info[$n]['cn'][0]; $email = $info[$n]['email'][0]; $id= $info[$n]['id'][0]; $dn = "cn=Device"; $filter="(objectclass=device)(userid=$id)"; $justthese = array('cn','system','guid','ID','userid'); $sr=ldap_search($ds, $dn, $filter, $justthese); $info = ldap_get_entries($ds, $sr); for ($n=0; $n<$info['count']; $n++) { $system = $info[$n]['system'][0]; $userid = $info[$n]['userid'][0]; } } ?> I'm sure there's a better way of writing this... that will make it faster. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248332-advice-on-database-query/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.