Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.DocVaultIndex.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Class.DocVaultIndex.php manages a full index
8  * for files attached to a Freedom document
9  *
10  * @author Anakeen
11  * @version $Id: Class.DocVaultIndex.php,v 1.8 2007/03/07 18:42:24 eric Exp $
12  * @package FDL
13  */
14 /**
15  */
16 
17 include_once ('Class.DbObj.php');
18 include_once ('Class.QueryDb.php');
19 include_once ('Class.Log.php');
20 
21 class DocVaultIndex extends DbObj
22 {
23  var $fields = array(
24  "docid",
25  "vaultid"
26  );
27 
28  var $id_fields = array(
29  "docid",
30  "vaultid"
31  );
32 
33  var $dbtable = "docvaultindex";
34 
35  var $order_by = "docid";
36  public $docid;
37  public $vaultid;
38  var $sqlcreate = "
39 create table docvaultindex ( docid int not null,
40  vaultid bigint not null
41  );
42 create index idx_docvid on docvaultindex(vaultid);
43 create unique index idx_docvaultindex on docvaultindex (docid, vaultid);";
44  /**
45  * return doc ids from a vault file
46  * @param int $vid vault id
47  * @return array object
48  */
49  function getDocIds($vid)
50  {
51  $t = array();
52  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
53  $query->basic_elem->sup_where = array(
54  "vaultid = $vid"
55  );
56  $t = $query->Query();
57 
58  return $t;
59  }
60  /**
61  * return first doc id from a vault file
62  * @param int $vid vault id
63  * @return int id of document
64  */
65  function getDocId($vid)
66  {
67  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
68  $query->AddQuery("vaultid = $vid");
69  $t = $query->Query(0, 1, "TABLE");
70  if (is_array($t)) return $t[0]["docid"];
71  return false;
72  }
73  /**
74  * return vault ids for a document
75  * @param int $docid document id
76  * @return array
77  */
78  function getVaultIds($docid)
79  {
80  if (!$docid) return array();
81  $query = new QueryDb($this->dbaccess, "DocVaultIndex");
82  $query->AddQuery("docid = $docid");
83  $t = $query->Query(0, 0, "TABLE");
84  $tvid = array();
85  if (is_array($t)) {
86  foreach ($t as $tv) {
87  $tvid[] = $tv["vaultid"];
88  }
89  }
90  return $tvid;
91  }
92 
93  function DeleteDoc($docid)
94  {
95  $err = $this->exec_query("delete from " . $this->dbtable . " where docid=" . $docid);
96  return $err;
97  }
98 
99  function DeleteVaultId($vid)
100  {
101  $err = $this->exec_query("delete from " . $this->dbtable . " where vaultid=" . $vid);
102  return $err;
103  }
104 }
exec_query($sql, $lvl=0, $prepare=false)
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen