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.php,v 1.5 2007/03/04 21:26:52 quipo Exp $
45
 
46
class MDB2_nonstandard {
47
    //contains the MDB2 object of the db once we have connected
48
    var $db;
49
 
50
    //contains the PHPUnit_TestCase object
51
    var $test;
52
 
53
    /**
54
     * Returns a driver-specific object
55
     */
56
    function factory($db, $test) {
57
        $classname = 'MDB2_nonstandard_'.$db->phptype;
58
        include_once $classname.'.php';
59
        if (class_exists($classname)) {
60
            $obj =& new $classname();
61
            $obj->db =& $db;
62
            $obj->test =& $test;
63
            return $obj;
64
        }
65
        return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
66
            'not capable', __FUNCTION__);
67
    }
68
 
69
    /**
70
     * Create a TRIGGER
71
     */
72
    function createTrigger($trigger_name, $table_name) {
73
        return $this->db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null,
74
            'not capable', __FUNCTION__);
75
    }
76
 
77
    /**
78
     * Check if getTriggerDefinition() returns the correct definition for the trigger
79
     */
80
    function checkTrigger($trigger_name, $table_name, $def) {
81
        $this->test->assertEquals(strtoupper($trigger_name), strtoupper($def['trigger_name']), 'Error getting trigger definition (name)');
82
        $this->test->assertEquals(strtoupper($table_name),  strtoupper($def['table_name']),   'Error getting trigger definition (table)');
83
        $this->test->assertEquals('AFTER',  $def['trigger_type'], 'Error getting trigger definition (type)');
84
        $this->test->assertEquals('UPDATE', $def['trigger_event'], 'Error getting trigger definition (event)');
85
        $this->test->assertTrue(is_string($def['trigger_body']), 'Error getting trigger definition (body)');
86
        $this->test->assertTrue($def['trigger_enabled'], 'Error getting trigger definition (enabled)');
87
        //$this->test->assertTrue(empty($def['trigger_comment']),  'Error getting trigger definition (comment)');
88
    }
89
 
90
    /**
91
     * Drop a TRIGGER
92
     */
93
    function dropTrigger($trigger_name, $table_name) {
94
        return $this->db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null,
95
            'not capable', __FUNCTION__);
96
    }
97
 
98
    /**
99
     * Create a VIEW
100
     */
101
    function createView($view_name, $table_name) {
102
        $query = 'CREATE VIEW '. $this->db->quoteIdentifier($view_name, true)
103
                .' (id) AS SELECT id FROM '
104
                . $this->db->quoteIdentifier($table_name, true) .' WHERE id > 1';
105
        return $this->db->exec($query);
106
    }
107
 
108
    /**
109
     * Drop a VIEW
110
     */
111
    function dropView($view_name) {
112
        return $this->db->exec('DROP VIEW '.$view_name);
113
    }
114
 
115
    /**
116
     * Create a FUNCTION
117
     */
118
    function createFunction($name) {
119
        return $this->db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null,
120
            'not capable', __FUNCTION__);
121
    }
122
 
123
    /**
124
     * Drop a FUNCTION
125
     */
126
    function dropFunction($name) {
127
        return $this->db->exec('DROP FUNCTION '.$name);
128
    }
129
}
130
?>