Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PHP versions 4 and 5                                                 |
4
// +----------------------------------------------------------------------+
5
// | Copyright (c) 2006-2007 Lorenzo Alberton                             |
6
// | All rights reserved.                                                 |
7
// +----------------------------------------------------------------------+
8
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB  |
9
// | API as well as database abstraction for PHP applications.            |
10
// | This LICENSE is in the BSD license style.                            |
11
// |                                                                      |
12
// | Redistribution and use in source and binary forms, with or without   |
13
// | modification, are permitted provided that the following conditions   |
14
// | are met:                                                             |
15
// |                                                                      |
16
// | Redistributions of source code must retain the above copyright       |
17
// | notice, this list of conditions and the following disclaimer.        |
18
// |                                                                      |
19
// | Redistributions in binary form must reproduce the above copyright    |
20
// | notice, this list of conditions and the following disclaimer in the  |
21
// | documentation and/or other materials provided with the distribution. |
22
// |                                                                      |
23
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
24
// | Lukas Smith nor the names of his contributors may be used to endorse |
25
// | or promote products derived from this software without specific prior|
26
// | written permission.                                                  |
27
// |                                                                      |
28
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
29
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
30
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
31
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
32
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
33
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
34
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
35
// |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
36
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
37
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
38
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
39
// | POSSIBILITY OF SUCH DAMAGE.                                          |
40
// +----------------------------------------------------------------------+
41
// | Author: Lorenzo Alberton <l.alberton@quipo.it>                       |
42
// +----------------------------------------------------------------------+
43
//
44
// $Id: MDB2_nonstandard_oci8.php,v 1.5 2007/03/04 22:28:23 quipo Exp $
45
 
46
class MDB2_nonstandard_oci8 extends MDB2_nonstandard {
47
 
48
    var $trigger_body = '';
49
    var $when_clause = 'new.id > 0';
50
 
51
    function createTrigger($trigger_name, $table_name) {
52
        $this->trigger_body = 'BEGIN INSERT INTO '.$table_name
53
            .' (id, somename, somedescription) VALUES'
54
            .' (:new.id+1, :new.somename, :new.somedescription); END '. $trigger_name .';';
55
        $query = 'CREATE OR REPLACE TRIGGER '. $trigger_name
56
                .' AFTER UPDATE ON '. $table_name
57
                .' FOR EACH ROW WHEN ('.$this->when_clause.') '
58
                . $this->trigger_body;
59
        return $this->db->exec($query);
60
    }
61
 
62
    function checkTrigger($trigger_name, $table_name, $def) {
63
        parent::checkTrigger($trigger_name, $table_name, $def);
64
        $this->test->assertEquals($this->trigger_body, $def['trigger_body']);
65
        $this->test->assertEquals($this->when_clause, $def['when_clause']);
66
    }
67
 
68
    function dropTrigger($trigger_name, $table_name) {
69
        return $this->db->exec('DROP TRIGGER '.$trigger_name);
70
    }
71
 
72
    function createFunction($name) {
73
        $query = 'CREATE FUNCTION '.$name.'(a IN INT, b IN INT)
74
RETURN INT AS
75
BEGIN
76
    RETURN a + b;
77
END;';
78
        return $this->db->exec($query);
79
    }
80
}
81
 
82
?>