private function id($category)
    {
        if (is_null($this->ids)) {
            $this->ids = array();
            $categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
            foreach ($categories as $row) {
                $this->ids[$row['category']] = $row['id'];
            }
        }
        if (!isset($this->ids[$category])) {
            $parent = 0;
            $previous = '';
            foreach (explode('/', $category) as $path) {
                if (!isset($this->ids[$previous.$path])) {
                    $this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
                }
                $parent = $this->ids[$previous.$path];
                $previous .= $path.'/';
            }
        }

        return $this->ids[$category];
    }
private function id($category)
    {
        if (is_null($this->ids)) {
            $this->ids = array();
            $categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
            foreach ($categories as $row) {
                $this->ids[$row['category']] = $row['id'];
            }
        }
        if (!isset($this->ids[$category])) {
            $parent = 0;
            $previous = '';
            foreach (explode('/', $category) as $path) {
                if (!isset($this->ids[$previous.$path])) {
                    $this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
                }
                $parent = $this->ids[$previous.$path];
                $previous .= $path.'/';
            }
        }

        return $this->ids[$category];
    }
private function id ( $ category ) { if ( is_null ( $ this -> ids ) ) { $ this -> ids = array ( ) ; $ categories = $ this -> db -> all ( 'SELECT category, id FROM categories' , '' , 'assoc' ) ; foreach ( $ categories as $ row ) { $ this -> ids [ $ row [ 'category' ] ] = $ row [ 'id' ] ; } } if ( ! isset ( $ this -> ids [ $ category ] ) ) { $ parent = 0 ; $ previous = '' ; foreach ( explode ( '/' , $ category ) as $ path ) { if ( ! isset ( $ this -> ids [ $ previous . $ path ] ) ) { $ this -> ids [ $ previous . $ path ] = $ this -> exec ( 'INSERT' , 'categories' , array ( $ previous . $ path , $ parent ) ) ; } $ parent = $ this -> ids [ $ previous . $ path ] ; $ previous .= $ path . '/' ; } } return $ this -> ids [ $ category ] ; }
Converts a category string into it's id.

@param string $category

@return int
Converts a category string into it s id .