/** * Returns the indexes for type $type. * * @param string $type * * @return array $indexInfo index information */ protected function getIndexes($type) { $table = $this->esc($type, TRUE); $indexes = $this->adapter->get("PRAGMA index_list('{$table}')"); $indexInfoList = array(); foreach ($indexes as $i) { $indexInfoList[$i['name']] = $this->adapter->getRow("PRAGMA index_info('{$i['name']}') "); $indexInfoList[$i['name']]['unique'] = $i['unique']; } return $indexInfoList; }
/** * @see QueryWriter::queryRecordLink */ public function queryRecordLink($sourceType, $destType, $sourceID, $destID) { list($sourceTable, $destTable, $linkTable, $sourceCol, $destCol) = $this->getRelationalTablesAndColumns($sourceType, $destType); $key = $this->getCacheKey(array($sourceType, $destType, $sourceID, $destID)); if ($this->flagUseCache && ($cached = $this->getCached($linkTable, $key))) { return $cached; } if ($sourceTable === $destTable) { $sql = "SELECT {$linkTable}.* FROM {$linkTable}\n\t\t\t\tWHERE ( {$sourceCol} = ? AND {$destCol} = ? ) OR\n\t\t\t\t ( {$destCol} = ? AND {$sourceCol} = ? ) -- keep-cache"; $row = $this->adapter->getRow($sql, array($sourceID, $destID, $sourceID, $destID)); } else { $sql = "SELECT {$linkTable}.* FROM {$linkTable}\n\t\t\t\tWHERE {$sourceCol} = ? AND {$destCol} = ? -- keep-cache"; $row = $this->adapter->getRow($sql, array($sourceID, $destID)); } $this->putResultInCache($linkTable, $key, $row); return $row; }