Created
November 27, 2013 15:31
-
-
Save psi-4ward/7677634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Initialize the system | |
*/ | |
define('TL_MODE', 'FE'); | |
require 'system/initialize.php'; | |
$tl_filesIDs = array('3', '4', '5', '6'); | |
$DB = \Database::getInstance(); | |
$DB->query('DROP TABLE IF EXISTS `update_test`'); | |
$DB->query(' | |
CREATE TABLE `update_test` ( | |
`id` int(9) unsigned auto_increment NOT NULL, | |
`orgid` int(9) unsigned NOT NULL, | |
`fld211` varchar(255) NOT NULL, | |
`fld30` int(9) unsigned NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
'); | |
foreach($tl_filesIDs as $id) { | |
$file = $DB->execute('SELECT * FROM tl_files WHERE id='.$id); | |
if(!$file->numRows) die("tl_files.id=$id not found!\n"); | |
$DB->prepare('INSERT INTO update_test SET fld211=?, fld30=?, orgid=?')->execute($file->path, $file->id, $file->id); | |
} | |
for($i=0; $i<3; $i++) | |
{ | |
$u = new \Database\Updater(); | |
$u->convertSingleField('update_test', 'fld211'); | |
$u->convertSingleField('update_test', 'fld30'); | |
foreach($tl_filesIDs as $id) | |
{ | |
$file = $DB->execute('SELECT * FROM tl_files WHERE id='.$id); | |
$newrow = $DB->execute('SELECT * FROM update_test WHERE orgid='.$id); | |
if($file->uuid != $newrow->fld211) die("Test FAILED for row {$newrow->id}\n"); | |
if($file->uuid != $newrow->fld30) die("Test FAILED for row {$newrow->id}\n"); | |
} | |
} | |
die("PASS\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment