[Tickets #5079] DataTree_SQL getId is buggy

bugs at bugs.horde.org bugs at bugs.horde.org
Wed Mar 7 17:38:19 UTC 2007


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=5079
-----------------------------------------------------------------------
 Ticket             | 5079
 Created By         | x3n at molinier.eu
 Summary            | DataTree_SQL getId is buggy
 Queue              | Horde Framework Packages
 Version            | HEAD
 Type               | Bug
 State              | Unconfirmed
 Priority           | 1. Low
 Owners             | 
-----------------------------------------------------------------------


x3n at molinier.eu (2007-03-07 09:38) wrote:

This bug has been originally posted by roel at gloudemans.info on the DEV
list, but I think here is the right place !

A short description: the function _getId in the file DataTree/Sql.php is
not working because the name stored in the database is not the absolute
name (with ':') but a relative one. The $name value is something like
'horde.syncml:user:device', and we are querying directly this name to the
database. Where is the orignal :

        $query = 'SELECT datatree_id FROM ' . $this->_params['table'] .
            ' WHERE group_uid = ? AND datatree_name = ?';
        $values = array($this->_params['group'], $name);
        Horde::logMessage('SQL Query by DataTree_sql::_getId(): ' .
$query, __FILE__, __LINE__, PEAR_LOG_DEBUG);

        $result = $this->_db->getOne($query, $values);
        if (is_a($result, 'PEAR_Error')) {
            return null;
        } else {
            return $result;
        }

I propuse his solution, which simply retrieves ID of parents node, to
create the root line. And then I'm asking the real name !

        $query = 'SELECT datatree_id FROM ' . $this->_params['table'] .
                 ' WHERE group_uid = ? AND datatree_name = ?' .
                 ' AND datatree_parents = ?';

        $rootLine=explode(':', $name);
        $id=array();

        foreach($rootLine as $node) {
          $result = $this->_db->getOne($query,
array($this->_params['group'],$node,count($id)?':'.implode(':',$id):''));
          if (is_a($result, 'PEAR_Error')) {
              return null;
          } else {
              array_push($id,$result);
          }
        }
        return $id[count($id)-1];

I d'ont if there is a better way to do that !

Best regards,


x3n
http://www.molinier.eu



More information about the bugs mailing list