| 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_mysql.php,v 1.4 2007/03/04 22:51:06 quipo Exp $
|
|
|
45 |
|
|
|
46 |
class MDB2_nonstandard_mysql extends MDB2_nonstandard {
|
|
|
47 |
|
|
|
48 |
var $trigger_body = '';
|
|
|
49 |
|
|
|
50 |
function createTrigger($trigger_name, $table_name) {
|
|
|
51 |
$this->trigger_body = 'BEGIN
|
|
|
52 |
UPDATE '. $table_name .' SET somedescription = OLD.somename WHERE id = NEW.id;
|
|
|
53 |
END';
|
|
|
54 |
$query = 'CREATE TRIGGER '. $trigger_name .' AFTER UPDATE ON '. $table_name .'
|
|
|
55 |
FOR EACH ROW '. $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 FUNCTION '.$name.'(a INT, b INT) RETURNS INT
|
|
|
70 |
RETURN a + b;';
|
|
|
71 |
return $this->db->exec($query);
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
?>
|