diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php index cc5b39119..bb77b9835 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php @@ -165,7 +165,7 @@ class SeedDMS_SQLiteFTS_Indexer { * @param string $query * @param array $limit array with elements 'limit' and 'offset' * @return boolean false in case of an error, otherwise array with elements - * 'count', 'hits', 'facets' + * 'count', 'hits', 'facets'. 'hits' is an array of SeedDMS_SQLiteFTS_QueryHit */ public function find($query, $limit=array()) { /* {{{ */ if(!$this->_conn) @@ -206,20 +206,21 @@ class SeedDMS_SQLiteFTS_Indexer { /** * Get a single document from index * - * @param integer $id id of document + * @param string $id id of document * @return boolean false in case of an error, otherwise true */ public function findById($id) { /* {{{ */ if(!$this->_conn) return false; - $sql = "SELECT ".$this->_rawid." FROM docs WHERE ".$this->_rawid."=".(int) $id; + $sql = "SELECT ".$this->_rawid.", documentid FROM docs WHERE documentid=".$this->_conn->quote($id); $res = $this->_conn->query($sql); $hits = array(); if($res) { while($rec = $res->fetch(PDO::FETCH_ASSOC)) { $hit = new SeedDMS_SQLiteFTS_QueryHit($this); $hit->id = $rec[$this->_rawid]; + $hit->documentid = $rec['documentid']; $hits[] = $hit; } } @@ -232,11 +233,11 @@ class SeedDMS_SQLiteFTS_Indexer { * @param integer $id id of index record * @return boolean false in case of an error, otherwise true */ - public function getDocument($id) { /* {{{ */ + public function getDocument($id, $content=true) { /* {{{ */ if(!$this->_conn) return false; - $sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path FROM docs WHERE documentid='D".$id."'"; + $sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path".($content ? ", content" : "")." FROM docs WHERE ".$this->_rawid."='".$id."'"; $res = $this->_conn->query($sql); $doc = false; if($res) { @@ -255,6 +256,8 @@ class SeedDMS_SQLiteFTS_Indexer { $doc->addField('users', $rec['users']); $doc->addField('status', $rec['status']); $doc->addField('path', $rec['path']); + if($content) + $doc->addField('content', $rec['content']); } return $doc; } /* }}} */ @@ -265,7 +268,7 @@ class SeedDMS_SQLiteFTS_Indexer { * @param integer $id id of folder * @return boolean false in case of an error, otherwise true */ - public function getFolder($id) { /* {{{ */ + public function __getFolder($id) { /* {{{ */ if(!$this->_conn) return false;