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