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_ibase.php,v 1.5 2007/03/04 21:32:31 quipo Exp $
45
 
46
class MDB2_nonstandard_ibase extends MDB2_nonstandard {
47
 
48
    var $trigger_body = 'AS
49
BEGIN
50
  NEW.somedescription = OLD.somename;
51
END';
52
 
53
    function createTrigger($trigger_name, $table_name) {
54
        $query = 'CREATE OR ALTER TRIGGER '. $trigger_name .' FOR '. $table_name .'
55
                  AFTER UPDATE '. $this->trigger_body .';';
56
        return $this->db->exec($query);
57
    }
58
 
59
    function checkTrigger($trigger_name, $table_name, $def) {
60
        parent::checkTrigger($trigger_name, $table_name, $def);
61
        $this->test->assertEquals($this->trigger_body, $def['trigger_body']);
62
    }
63
 
64
    function dropTrigger($trigger_name, $table_name) {
65
        return $this->db->exec('DROP TRIGGER '.$trigger_name);
66
    }
67
 
68
    function createFunction($name) {
69
        $query = 'CREATE PROCEDURE '.$name.'(N1 DECIMAL(6,2), N2 DECIMAL(6,2))
70
RETURNS (
71
  res DECIMAL(6,2)
72
)
73
AS
74
BEGIN
75
  FOR
76
    SELECT (:N1 + :N2) FROM RDB$DATABASE INTO :res
77
  DO
78
    BEGIN
79
      SUSPEND;
80
    END
81
END';
82
        return $this->db->exec($query);
83
    }
84
 
85
    function dropFunction($name) {
86
        return $this->db->exec('DROP PROCEDURE '.$name);
87
    }
88
}
89
 
90
?>