* Unfortunately propel's reverse task doesn't get everything right, and sometimes schema.xml requires hand-editing. * However, this makes it painful to make db changes b/c you'd have to add the new DB changes to schema.xml manually since * the reverse task would blow away your hand-edits. * * Instead of the above nightmare, just encode all of your hand-edits into this file, and whenever you "reverse" your db, run fix-schema afterwards. */ require_once getenv('PHOCOA_PROJECT_CONF'); $schemaFile = APP_ROOT . '/propel-build/schema.xml'; $xml = simplexml_load_file($schemaFile); // add WFObject as the BasePeer class $databaseEl = $xml->xpath('//database'); $databaseEl[0]['basePeer'] = 'BasePeer '; // prune unused tables $unusedTables = array('//table[@name="mp_version"]'); foreach ($unusedTables as $xpath) { removeNode($xml, $xpath, 'all'); } // prunce all defaultValue="now()" attributes to keep propel from f'n up our times $sqlDefaultNowDefaultTimestamps = $xml->xpath('//table/column[@defaultValue="now()"]'); foreach ($sqlDefaultNowDefaultTimestamps as $nodeToFix) { unset($nodeToFix[0]['defaultValue']); } // write out munged XML tree file_put_contents($schemaFile, $xml->asXML()); function removeNode($xml, $path, $multi = 'one') { $result = $xml->xpath($path); # for wrong $path if (!isset($result[0])) { return false; }
} } //get question details and update the database if ($execute) { if (addNewNode($questionHTML, _POST("posX"), _POST("posY"))) { echo json_encode(array("status" => 600, "message" => "Successfully Added a new node", "posX" => intval(_POST("posX")), "posY" => intval(_POST("posY")), "nodeId" => intval(mysql_insert_id()))); } else { echo json_encode(array("status" => 601, "message" => "Unable to add a new node")); } } else { echo json_encode(array("status" => 601, "message" => "Unable to add , \$exec fail")); } break; case "removeNode": //delete question from the database and remove all paths attached to it if (removeNode(_POST('level'))) { echo json_encode(array("status" => 600, "message" => "Successfully Removed Node")); } else { echo json_encode(array("status" => 601, "message" => "Unable to remove Node")); } break; case "addPath": //get from and to data and create a new entry in the answer table if (addNewPath(_POST('from'), _POST('to'), _POST('key'))) { echo json_encode(array("status" => 600, "message" => "Successfully Added Path")); } else { echo json_encode(array("status" => 601, "message" => "Unable to add a new path")); } break; case "removePath": //get from and to data and remove a path from the answer table