Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_install_utils_ProceduresCreator | |
0.00% |
0 / 21 |
|
0.00% |
0 / 4 |
110 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
42 | |||
| getSQLParser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSQLParser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| load | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; under version 2 |
| 8 | * of the License (non-upgradable). |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 20 | * (under the project TAO & TAO2); |
| 21 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 22 | * (under the project TAO-TRANSFER); |
| 23 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 24 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * Create procedure for uri provider |
| 31 | * |
| 32 | * @author Lionel Lecaque, lionel@taotesting.com |
| 33 | */ |
| 34 | class tao_install_utils_ProceduresCreator |
| 35 | { |
| 36 | /** |
| 37 | * |
| 38 | * @var unknown |
| 39 | */ |
| 40 | private $connection; |
| 41 | /** |
| 42 | * |
| 43 | * @var tao_install_utils_SimpleSQLParser |
| 44 | */ |
| 45 | private $sqlParser; |
| 46 | |
| 47 | /** |
| 48 | * |
| 49 | * @author Lionel Lecaque, lionel@taotesting.com |
| 50 | * @param string $driver |
| 51 | * @param unknown $connection |
| 52 | * @throws tao_install_utils_SQLParsingException |
| 53 | */ |
| 54 | public function __construct($driver, $connection) |
| 55 | { |
| 56 | |
| 57 | $this->connection = $connection; |
| 58 | switch ($driver) { |
| 59 | case 'pdo_mysql': |
| 60 | $this->setSQLParser(new tao_install_utils_MysqlProceduresParser()); |
| 61 | break; |
| 62 | |
| 63 | case 'pdo_pgsql': |
| 64 | $this->setSQLParser(new tao_install_utils_PostgresProceduresParser()); |
| 65 | break; |
| 66 | |
| 67 | case 'pdo_oci': |
| 68 | $this->setSQLParser(new tao_install_utils_CustomProceduresParser()); |
| 69 | break; |
| 70 | |
| 71 | case 'pdo_sqlsrv': |
| 72 | $this->setSQLParser(new tao_install_utils_CustomProceduresParser()); |
| 73 | break; |
| 74 | |
| 75 | default: |
| 76 | throw new tao_install_utils_SQLParsingException('Could not find Parser for driver ' . $driver); |
| 77 | } |
| 78 | } |
| 79 | /** |
| 80 | * |
| 81 | * @author Lionel Lecaque, lionel@taotesting.com |
| 82 | * @return tao_install_utils_SimpleSQLParser |
| 83 | */ |
| 84 | private function getSQLParser() |
| 85 | { |
| 86 | return $this->sqlParser; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * |
| 91 | * @author Lionel Lecaque, lionel@taotesting.com |
| 92 | * @param tao_install_utils_SimpleSQLParser $sqlParser |
| 93 | */ |
| 94 | private function setSQLParser($sqlParser) |
| 95 | { |
| 96 | $this->sqlParser = $sqlParser; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * |
| 101 | * @author Lionel Lecaque, lionel@taotesting.com |
| 102 | * @param string $file |
| 103 | */ |
| 104 | public function load($file) |
| 105 | { |
| 106 | $parser = $this->getSQLParser(); |
| 107 | $parser->setFile($file); |
| 108 | $parser->parse(); |
| 109 | |
| 110 | foreach ($parser->getStatements() as $statement) { |
| 111 | $this->connection->executeUpdate($statement); |
| 112 | } |
| 113 | } |
| 114 | } |