Update of /cvsroot/stack/stack-dev/other/adminscripts
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29766/other/adminscripts
Added Files:
Tag: question_reporting
itemTraverseAndOp.php
Log Message:
Merging from the current HEAD into question_reporting. Apologies in advance if this all goes horribly wrong.
--- NEW FILE: itemTraverseAndOp.php ---
<?php
die();// For one-time use only. Modify, enable, use and disable!
/*
* Handy script to perform an operation across all Items in the database.
* First use was changing the underscores to hyphens in question names.
*/
session_start();
$configFile = '../../config.php';
require($configFile);
$config = new stackConfig();
global $config;
$root = $config->get('docroot');
require_once $root.'/lib/database/StackDBADOdb.php';
require_once $root.'/lib/items/Item.php';
$db = new StackDBADOdb();
$db->connect();
// which questions to modify
$field = 'questionName';
$sql = "SELECT questionID, $field FROM stackquestion";
$db->query($sql);
// get list of questions
for ($i=0; $i<$db->noRows(); $i++) {
$qList[$db->result($i, 'questionID')] = $db->result($i, $field);
}
echo "<pre>";
foreach($qList as $qID => $content) {
$replacement = str_replace('_', '-', $content);
$options = NULL;
$item = new Item($options, $qID);
$item->questionName->setSelection($replacement);
echo $content." -> ".$item->$field->getSelection()."\n";
$db->query("UPDATE stackquestion SET $field='$replacement' WHERE questionID=$qID");
$item->store();
}
echo "</pre>";
?>
|