]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/PDO_oci8.php
rcs_id no longer makes sense with Subversion global version number
[SourceForge/phpwiki.git] / lib / WikiDB / backend / PDO_oci8.php
1 <?php // -*-php-*-
2 // rcs_id('$Id$');
3
4 /*
5  Copyright 2007 $ThePhpWikiProgrammingTeam
6
7  This file is part of PhpWiki.
8
9  PhpWiki is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  PhpWiki is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with PhpWiki; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 */ 
23
24 /**
25  * @author: Reini Urban
26  */
27 require_once('lib/WikiDB/backend/PDO.php');
28
29 class WikiDB_backend_PDO_oci8
30 extends WikiDB_backend_PDO
31 {
32
33     function optimize() {
34         // Do nothing here -- Leave that for the DBA
35         // Cost Based Optimizer tuning vary from version to version
36         return 1;
37     }
38
39     /**
40      * Lock all tables we might use.
41      */
42     function _lock_tables($write_lock=true) {
43         $dbh = &$this->_dbh;
44         
45         // Not sure if we really need to lock tables here, the Oracle row
46         // locking mechanism should be more than enough
47         // For the time being, lets stay on the safe side and lock...
48         if ($write_lock) {
49             // Next line is default behaviour, so just skip it
50             // $dbh->query("SET TRANSACTION READ WRITE");
51             foreach ($this->_table_names as $table) {
52                 $dbh->exec("LOCK TABLE $table IN EXCLUSIVE MODE");
53             }
54         } else {
55             // Just ensure read consistency
56             $dbh->exec("SET TRANSACTION READ ONLY");
57         }
58     }
59
60     function backendType() {
61         return 'oci8';
62     }
63     function write_accesslog(&$entry) {
64         global $request;
65         $dbh = &$this->_dbh;
66         $log_tbl = $entry->_accesslog->logtable;
67         $sth = $dbh->prepare("INSERT INTO $log_tbl"
68                              . " (time_stamp,remote_host,remote_user,request_method,request_line,request_args,"
69                              .   "request_file,request_uri,request_time,status,bytes_sent,referer,agent,request_duration)"
70                              . " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
71         // Either use unixtime as %d (long), or the native timestamp format.
72         $sth->bindParam(1, date('d-M-Y H:i:s', $entry->time));
73         $sth->bindParam(2, $entry->host, PDO_PARAM_STR, 100);
74         $sth->bindParam(3, $entry->user, PDO_PARAM_STR, 50);
75         $sth->bindParam(4, $entry->request_method, PDO_PARAM_STR, 10);
76         $sth->bindParam(5, $entry->request, PDO_PARAM_STR, 255);
77         $sth->bindParam(6, $entry->request_args, PDO_PARAM_STR, 255);
78         $sth->bindParam(7, $entry->request_uri, PDO_PARAM_STR, 255);
79         $sth->bindParam(8, $entry->_ncsa_time($entry->time), PDO_PARAM_STR, 28);
80         $sth->bindParam(9, $entry->time, PDO_PARAM_INT);
81         $sth->bindParam(10,$entry->status, PDO_PARAM_INT);
82         $sth->bindParam(11,$entry->size, PDO_PARAM_INT);
83         $sth->bindParam(12,$entry->referer, PDO_PARAM_STR, 255);
84         $sth->bindParam(13,$entry->user_agent, PDO_PARAM_STR, 255);
85         $sth->bindParam(14,$entry->duration, PDO_PARAM_FLOAT);
86         $sth->execute();
87     }
88 }
89
90 // (c-file-style: "gnu")
91 // Local Variables:
92 // mode: php
93 // tab-width: 8
94 // c-basic-offset: 4
95 // c-hanging-comment-ender-p: nil
96 // indent-tabs-mode: nil
97 // End:   
98 ?>