original_string: 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];
      }
code: 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];
      }
code_tokens: 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 ] ; }
docstring: Converts a category string into it's id.
  
  @param string $category
  
  @return int
docstring_tokens: Converts a category string into it s id .