Subversion Repositories oidplus

Rev

Rev 296 | Rev 386 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
360 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2020 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
// DATABASE UPDATE 202 -> 203
21
// This script will be included by OIDplusDatabaseConnection.class.php inside function afterConnect().
22
// Parameters: $this is the OIDplusDatabaseConnection class
23
//             $version is the current version (this script MUST increase the number by 1 when it is done)
24
 
25
if (!isset($version)) throw new OIDplusException(_L('Argument "%1" is missing; was the file included in a wrong way?','version'));
26
if (!isset($this))    throw new OIDplusException(_L('Argument "%1" is missing; was the file included in a wrong way?','this'));
27
 
28
if ($this->transaction_supported()) $this->transaction_begin();
29
 
30
if ($this->getSlang()::id() == 'mssql') {
31
        $this->query("CREATE FUNCTION [dbo].[getOidArc] (@strList varchar(512), @maxArcLen int, @occurence int)
32
        RETURNS varchar(512) AS
33
        BEGIN
34
                DECLARE @intPos int
35
 
36
                DECLARE @cnt int
37
                SET @cnt = 0
38
 
39
                if SUBSTRING(@strList, 1, 4) <> 'oid:'
40
                begin
41
                        RETURN ''
42
                end
43
 
44
                SET @strList = RIGHT(@strList, LEN(@strList)-4)
45
 
46
                WHILE CHARINDEX('.',@strList) > 0
47
                BEGIN
48
                        SET @intPos=CHARINDEX('.',@strList)
49
                        SET @cnt = @cnt + 1
50
                        IF @cnt = @occurence
51
                        BEGIN
52
                                SET @strList = LEFT(@strList,@intPos-1)
53
                                RETURN REPLICATE('0', @maxArcLen-len(@strList)) + @strList
54
                        END
55
                        SET @strList = RIGHT(@strList, LEN(@strList)-@intPos)
56
                END
57
                IF LEN(@strList) > 0
58
                BEGIN
59
                        SET @cnt = @cnt + 1
60
                        IF @cnt = @occurence
61
                        BEGIN
62
                                RETURN REPLICATE('0', @maxArcLen-len(@strList)) + @strList
63
                        END
64
                END
65
 
66
                RETURN REPLICATE('0', @maxArcLen)
67
        END");
68
}
69
 
70
$version = 203;
71
$this->query("UPDATE ###config SET value = ? WHERE name = 'database_version'", array($version));
72
 
73
if ($this->transaction_supported()) $this->transaction_commit();