I posted something on Google Groups not sure if it worked or what or whether you need to approve the comment, but just in case you didn't I made some bug fixes to TableGear.php. I have posted the function below with comments around the change I made. It fixes the problem where when using pagination the primary_key and auto_increment classes don't get added to the header. So here it is.
function _fetchHeaders()
{
$headers = array();
if($this->form && $this->editable) array_push($headers, array("field" => "EDIT", "html" => $this->headers["EDIT"], "attrib" => array("class" => $this->_checkColumnClass("EDIT"))));
if(count($this->data) > 0){
$firstRow = reset($this->data);
$column = 1;
foreach($firstRow["data"] as $field => $data){
$sortable = $this->_testForOption("sortable", $field, $column) ? true : false;
$sortType = $this->_getSortType($field);
$class = $this->_addClass("sortable", null, $sortable);
$class = $this->_addClass($sortType, $class);
if($this->primaryKeyColumnsByName[$field]){
$class = $this->_addClass("primary_key", $class);
if($this->primaryKeyColumnsByName[$field]["auto"]){
$class = $this->_addClass("auto_increment", $class);
}
}
if($this->headers[$field]) $userHeader = $this->headers[$field];
elseif($this->headers[$column]) $userHeader = $this->headers[$column];
else $userHeader = null;
$html = null;
if(is_array($userHeader)){
$html = $userHeader["html"];
$class = $this->_addClass($userHeader["class"], $class);
} elseif(is_string($userHeader)){
$html = $userHeader;
}
if(!$html && $this->autoHeaders) $html = $this->_autoFormatHeader($field);
// Match sorting field
preg_match('/^\w+/', $this->database["sort"], $match);
$sort = $match[0];
$desc = preg_match('/desc\s*$/i', $this->database["sort"]) > 0;
$carat = array("tag" => "span", "attrib" => array("class" => "carat"));
if($sort == $field){
if($desc){
$desc = null;
$carat["html"] = "▼";
} else {
$desc = "true";
$carat["html"] = "▲";
}
}
$html = array(array("tag" => "span", "html" => $html), $carat);
if($this->pagination && $this->pagination["totalPages"] != 1){
$href = $this->_modifyURIParams(array("sort" => $field, "desc" => $desc, "page" => null));
$link = array("tag" => "a", "html" => $html, "attrib" => array("href" => $href));
//There was a bug in this section, the primary_key and auto_increment tags weren't getting added
//when pagination was in use and more than one page
$header = array("html" => $link, "attrib" => array("class" => $class, "id" => $userHeader["id"]));
} else {
$header = array("html" => $html, "attrib" => array("class" => $class, "id" => $userHeader["id"]));
}
array_push($headers, $header);
$column++;
}
} elseif($this->connection){
if(!$this->database["table"]) return;
$columns = $this->query("SHOW COLUMNS FROM " . $this->database["table"]);
if(!$columns) return;
foreach($columns as $column){
$field = $column["Field"];
$header["field"] = $field;
$class = "";
if($this->autoHeaders) $header["html"] = $this->_autoFormatHeader($field);
else $header["html"] = $field;
if($column["Key"] == "PRI"){
$class = $this->_addClass("primary_key", $class);
}
if(stripos($column["Extra"], "auto_increment") !== false){
$class = $this->_addClass("auto_increment", $class);
}
$header["attrib"] = array("class" => $class);
array_push($headers, $header);
}
}
if($this->allowDelete && $this->form) array_push($headers, array("field" => "DELETE", "html" => $this->headers["DELETE"], "attrib" => array("class" => $this->_checkColumnClass("DELETE"))));
return $headers;
}