icon = PMA_Util::getImage('b_props.png', __('Structure')); break; case 'tbl_select.php': $this->icon = PMA_Util::getImage('b_search.png', __('Search')); break; case 'tbl_change.php': $this->icon = PMA_Util::getImage('b_insrow.png', __('Insert')); break; case 'tbl_sql.php': $this->icon = PMA_Util::getImage('b_sql.png', __('SQL')); break; case 'sql.php': $this->icon = PMA_Util::getImage('b_browse.png', __('Browse')); break; } $this->links = array( 'text' => $GLOBALS['cfg']['DefaultTabTable'] . '?server=' . $GLOBALS['server'] . '&db=%2$s&table=%1$s' . '&pos=0&token=' . $GLOBALS['token'], 'icon' => $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] . '?server=' . $GLOBALS['server'] . '&db=%2$s&table=%1$s&token=' . $GLOBALS['token'] ); $this->classes = 'table'; } /** * Returns the number of children of type $type present inside this container * This method is overridden by the Node_Database and Node_Table classes * * @param string $type The type of item we are looking for * ('columns' or 'indexes') * @param string $searchClause A string used to filter the results of the query * * @return int */ public function getPresence($type = '', $searchClause = '') { $retval = 0; $db = $this->realParent()->real_name; $table = $this->real_name; switch ($type) { case 'columns': $db = PMA_Util::sqlAddSlashes($db); $table = PMA_Util::sqlAddSlashes($table); $query = "SELECT COUNT(*) "; $query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` "; $query .= "WHERE `TABLE_NAME`='$table' "; $query .= "AND `TABLE_SCHEMA`='$db'"; $retval = (int)$GLOBALS['dbi']->fetchValue($query); break; case 'indexes': $db = PMA_Util::backquote($db); $table = PMA_Util::backquote($table); $query = "SHOW INDEXES FROM $table FROM $db"; $retval = (int)$GLOBALS['dbi']->numRows( $GLOBALS['dbi']->tryQuery($query) ); break; case 'triggers': $db = PMA_Util::sqlAddSlashes($db); $table = PMA_Util::sqlAddSlashes($table); $query = "SELECT COUNT(*) "; $query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` "; $query .= "WHERE `EVENT_OBJECT_SCHEMA`='$db' "; $query .= "AND `EVENT_OBJECT_TABLE`='$table'"; $retval = (int)$GLOBALS['dbi']->fetchValue($query); break; default: break; } return $retval; } /** * Returns the names of children of type $type present inside this container * This method is overridden by the Node_Database and Node_Table classes * * @param string $type The type of item we are looking for * ('tables', 'views', etc) * @param int $pos The offset of the list within the results * @param string $searchClause A string used to filter the results of the query * * @return array */ public function getData($type, $pos, $searchClause = '') { $maxItems = $GLOBALS['cfg']['MaxNavigationItems']; $retval = array(); $db = $this->realParent()->real_name; $table = $this->real_name; switch ($type) { case 'columns': $db = PMA_Util::sqlAddSlashes($db); $table = PMA_Util::sqlAddSlashes($table); $query = "SELECT `COLUMN_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` "; $query .= "WHERE `TABLE_NAME`='$table' "; $query .= "AND `TABLE_SCHEMA`='$db' "; $query .= "ORDER BY `COLUMN_NAME` ASC "; $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); break; case 'indexes': $db = PMA_Util::backquote($db); $table = PMA_Util::backquote($table); $query = "SHOW INDEXES FROM $table FROM $db"; $handle = $GLOBALS['dbi']->tryQuery($query); if ($handle !== false) { $count = 0; while ($arr = $GLOBALS['dbi']->fetchArray($handle)) { if (! in_array($arr['Key_name'], $retval)) { if ($pos <= 0 && $count < $maxItems) { $retval[] = $arr['Key_name']; $count++; } $pos--; } } } break; case 'triggers': $db = PMA_Util::sqlAddSlashes($db); $table = PMA_Util::sqlAddSlashes($table); $query = "SELECT `TRIGGER_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` "; $query .= "WHERE `EVENT_OBJECT_SCHEMA`='$db' "; $query .= "AND `EVENT_OBJECT_TABLE`='$table' "; $query .= "ORDER BY `TRIGGER_NAME` ASC "; $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); break; default: break; } return $retval; } /** * Returns the type of the item represented by the node. * * @return string type of the item */ protected function getItemType() { return 'table'; } } ?>