function savePlanState($plans, $workflowID, $formName) { $table = 'workflowState'; $planValues = array(); $planValues['workflowid'] = $workflowID; $planValues['formName'] = $formName; $planValues['state'] = addslashes(serialize($plans)); dbs::irrecord($table, $planValues, true); }
function addArchiveWorkflowUnit($workflowID) { $table = 'workflowArchive'; $archiveValues = array(); $archiveValues['workflowid'] = $workflowID; $archiveValues['timestamp'] = dbs::selattribute('timestamp', 'workflow', 'workflowId=' . $workflowID); $archiveValues['plan'] = addslashes(serialize(graphPlanDatabaseAccess::getPlanGraphList($workflowID))); //$planValues['state'] = addslashes(serialize($plans)); dbs::irrecord($table, $archiveValues, false); }
function updateDatabases($xmlPackage, $workflowId, $formData, $goal) { global $db; $db = connect($xmlPackage->getDb()); debug::message("connect to db:" . $xmlPackage->getDb() . '<br>'); $newDataItem = new coreWorkflowDataPacket($workflowId, array()); $tables = $xmlPackage->getTables(); if (sizeof($tables) > 0) { //For each table for ($tableIndex = 0; $tableIndex < sizeof($tables); $tableIndex++) { $table = $tables[$tableIndex]->getTableName(); $valsArray['workflowId'] = $workflowId; $fields = $tables[$tableIndex]->getDbFields(); //The fields specificed for ($index = 0; $index < sizeof($fields); $index++) { $field = $fields[$index]; $valsArray[$field] = addslashes($formData[$field]); } //Does this workflow item already exist in the table $sql_query = "workflowId='{$workflowId}'"; if (dbpear::numRecords($table, "{$sql_query}")) { $keyName = dbs::getprimarykey($table); $keyValue = dbpear::selAttribute($keyName, $table, $sql_query); dbs::updaterecord($table, $valsArray, $keyName, $keyValue); } else { dbs::irrecord($table, $valsArray, false); } $db = connect('iWFMS'); } $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); if (!$goal) { //We are not at the goal node //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } else { //We are at the goal node xmlPackage::displayArchiveItem($xmlPackage, $workflowId, 'workflowArchive', 'Current archived workflow item', 'archive'); } } else { $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } }
function dbmanagement_simple($table, $key, &$keyvalue, &$mode, $process, $vals) { global $sql_debug; if ($process == 'delete') { // Delete the record from table dbs::delrecord($table, $key, $keyvalue); $mesg = DELETED; $mode = 'preview'; } elseif ($process == 'add' || $process == 'edit') { // generate table column field names $cols = dbs::genfieldnames($table, '0'); if (!empty($keyvalue)) { /* this is an existing record adjust the columns and values parts of the replace sql statement */ $cols = "`" . $key . "`, " . $cols; $vals = "'" . $keyvalue . "', " . $vals; $request = "REPLACE"; } else { // this is a new record so set the insert sql statement $request = "INSERT"; } // run the sql for the live database echo $cols; echo $vals; dbs::irrecord($request, $table, $cols, $vals); $mesg = SAVED; // get the primary key for the previously inserted record if (empty($keyvalue)) { $row = dbs::getlast(); $keyvalue = $row[0]; } // set return mode $mode = "edit"; } return $mesg; }
if ($model['workflowCaching']) { saveCachePlans($planGraphList, $keyinserted, $modelId); } else { savePlans($planGraphList, $keyinserted, true); } $newstoptime = time::stoptiming() - $stoptime; performance::message("Database updating"); echo '<br><Br>'; systemMessages::message("Plan generation complete!"); systemMessages::message("Number of plans:" . sizeof($planGraphList)); } } else { $workFlowvalues = array(); $workFlowvalues['timestamp'] = $modified = time::ts_unix_mysql(time::timestamp()); //Create a new workflow item $keyinserted = dbs::irrecord('workflow', $workFlowvalues, false); $planGraphList = dbs::selrecord('plan', 'workflowcachingstore', "modelId={$modelId}", 0, 3); savePlans($planGraphList, $keyinserted, false); echo '<br><Br>'; systemMessages::message("Plan generation using caching feature complete!"); systemMessages::message("Number of plans:" . sizeof($planGraphList)); } function savePlans($planGraphList, $workflowKey, $seralise) { $planValues = array(); $dbValues = array(); for ($index = 0; $index < sizeof($planGraphList); $index++) { if ($seralise) { $plan = addslashes(serialize($planGraphList[$index])); } else { $plan = addslashes($planGraphList[$index]);
<?php include '../includes/config/database.php'; include_once '../includes/library/library_db_mysql.php'; include_once '../includes/library/library_arrays.php'; $table = 'text1'; $field = 'text1'; $key = 'text1id'; $updatearray['workflowId'] = 1; $updatearray[$field] = ${$field}; dbs::irrecord($table, $updatearray, false); dbs::updaterecord($table, $updatearray, $key, $keyvalue); header("Location: ../mockup/index.php");
function testDatabaseInsertDelete() { $this->assertFalse(dbs::irrecord('', array(), false)); $this->assertFalse(dbs::irrecord('table', array(), false)); }
$root = "../"; $pageref = "admin_groups.php"; $sql_debug = true; include_once '../includes/commonPages/system_header.php'; // Database setup variables $table = "groups"; $key = "groupid"; $identifier = "name"; $mesg = ''; if ($process) { switch ($process) { case 'delete': dbs::delrecord($table, $key, ${$key}); $mesg = 'Deleted!'; break; case 'add': $vals['name'] = $name; $vals['members'] = $groupmembers; dbs::irrecord($table, $vals, false); $mesg = 'Added!'; break; } } if (!isset($mode) || $mode == 'preview') { // show preview page include_once 'preview/' . str_replace('.php', '', $pageref) . '_preview.php'; } elseif ($mode == 'add' || $mode == 'edit') { // show edit page include_once 'edit/' . str_replace('.php', '', $pageref) . '_edit.php'; } include_once '../includes/commonPages/system_footer.php';