|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Christian Kuhn <lolli@schwarzbu.ch> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * A helper class for handling PDO databases 00030 * Backport of FLOW3 class PdoHelper, last synced version: 3528 00031 * 00032 * @author Karsten Dambekalns <karsten@typo3.org> 00033 * @package TYPO3 00034 * @subpackage t3lib 00035 * @version $Id$ 00036 */ 00037 class t3lib_PdoHelper { 00038 00039 /** 00040 * Pumps the SQL into the database. Use for DDL only. 00041 * 00042 * Important: key definitions with length specifiers (needed for MySQL) must 00043 * be given as "field"(xyz) - no space between double quote and parenthesis - 00044 * so they can be removed automatically. 00045 * 00046 * @param PDO $databaseHandle 00047 * @param string $pdoDriver 00048 * @param string $pathAndFilename 00049 * @return void 00050 * @author Karsten Dambekalns <karsten@typo3.org> 00051 */ 00052 static public function importSql(PDO $databaseHandle, $pdoDriver, $pathAndFilename) { 00053 $sql = file($pathAndFilename, FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES); 00054 00055 // Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db 00056 if ($pdoDriver !== 'mysql') { 00057 $sql = preg_replace('/"\([0-9]+\)/', '"', $sql); 00058 } 00059 00060 $statement = ''; 00061 foreach ($sql as $line) { 00062 $statement .= ' ' . trim($line); 00063 if (substr($statement, -1) === ';') { 00064 $databaseHandle->exec($statement); 00065 $statement = ''; 00066 } 00067 } 00068 } 00069 } 00070 00071 if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pdohelper.php']) { 00072 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_pdohelper.php']); 00073 } 00074 00075 ?>
1.8.0