| // +----------------------------------------------------------------------+ // // $Id: MDB2_nonstandard_mssql.php,v 1.2 2007/03/04 21:27:44 quipo Exp $ class MDB2_nonstandard_mssql extends MDB2_nonstandard { var $trigger_body = ''; function createTrigger($trigger_name, $table_name) { $this->trigger_body = 'CREATE TRIGGER '. $trigger_name .' ON '. $table_name .' FOR UPDATE AS DECLARE @oldName VARCHAR(100) DECLARE @newId INTEGER SELECT @oldName = (SELECT somename FROM Deleted) SELECT @newId = (SELECT id FROM Inserted) BEGIN UPDATE '. $table_name .' SET somedescription = @oldName WHERE id = @newId; END;'; return $this->db->exec($this->trigger_body); } function checkTrigger($trigger_name, $table_name, $def) { parent::checkTrigger($trigger_name, $table_name, $def); $this->test->assertEquals($this->trigger_body, $def['trigger_body']); echo '
';
        var_dump($this->trigger_body);
        var_dump($def['trigger_body']);
    }

    function dropTrigger($trigger_name, $table_name) {
        return $this->db->exec('DROP TRIGGER '.$trigger_name);
    }
    
    function createFunction($name) {
        $query = 'CREATE FUNCTION '.$name.'(@Number1 Decimal(6,2), @Number2 Decimal(6,2))
RETURNS Decimal(6,2)
BEGIN
    DECLARE @Result Decimal(6,2)
    SET @Result = @Number1 + @Number2
    RETURN @Result
END';
        return $this->db->exec($query);
    }
}

?>