本文整理汇总了PHP中tree::new_node方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::new_node方法的具体用法?PHP tree::new_node怎么用?PHP tree::new_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::new_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrate_testcases
/**
* migrate_testcases
*/
function migrate_testcases(&$dbHandler, $tableSet)
{
// TL 1.8
// --
// -- Table structure for table "tcversions"
// --
// CREATE TABLE "tcversions" (
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES nodes_hierarchy (id),
// "tc_external_id" INT NULL,
// "version" INTEGER NOT NULL DEFAULT '1',
// "summary" TEXT NULL DEFAULT NULL,
// "steps" TEXT NULL DEFAULT NULL,
// "expected_results" TEXT NULL DEFAULT NULL,
// "importance" INT2 NOT NULL DEFAULT '2',
// "author_id" BIGINT NULL DEFAULT NULL REFERENCES users (id),
// "creation_ts" TIMESTAMP NOT NULL DEFAULT now(),
// "updater_id" BIGINT NULL DEFAULT NULL REFERENCES users (id),
// "modification_ts" TIMESTAMP NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "is_open" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
// TL 1.9
// --
// -- Table structure for table "tcversions"
// --
// CREATE TABLE /*prefix*/tcversions(
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/nodes_hierarchy (id),
// "tc_external_id" INT NULL,
// "version" INTEGER NOT NULL DEFAULT '1',
// "layout" INTEGER NOT NULL DEFAULT '1',
// "summary" TEXT NULL DEFAULT NULL,
// "preconditions" TEXT NULL DEFAULT NULL,
// "importance" INT2 NOT NULL DEFAULT '2',
// "author_id" BIGINT NULL DEFAULT NULL REFERENCES /*prefix*/users (id),
// "creation_ts" TIMESTAMP NOT NULL DEFAULT now(),
// "updater_id" BIGINT NULL DEFAULT NULL REFERENCES /*prefix*/users (id),
// "modification_ts" TIMESTAMP NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "is_open" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
//
//
// --
// -- Table structure for table "tcsteps"
// --
// CREATE TABLE /*prefix*/tcsteps (
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/nodes_hierarchy (id),
// "step_number" INT NOT NULL DEFAULT '1',
// "actions" TEXT NULL DEFAULT NULL,
// "expected_results" TEXT NULL DEFAULT NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
// do test cases exist?
$sql = " SELECT TCV.id,NHTC.name AS name FROM {$tableSet['tcversions']} TCV " . " JOIN {$tableSet['nodes_hierarchy']} NHV ON NHV.id=TCV.id " . " JOIN {$tableSet['nodes_hierarchy']} NHTC ON NHTC.id=NHV.parent_id ";
echo 'Step - Test Case Migration - STARTED <br> ';
$itemSet = $dbHandler->get_recordset($sql);
if (!is_null($itemSet) && count($itemSet) > 0) {
echo 'Working - Test Case Migration <br> ';
$tree_mgr = new tree($dbHandler);
$node_types_descr_id = $tree_mgr->get_available_node_types();
$node_types_id_descr = array_flip($node_types_descr_id);
// STEP 1 - Populate in bulk mode tcsteps table.
//
// ALL FIELDS - tcversions 1.8
// 1.8 id,tc_external_id,version,summary,steps,expected_results,importance,author_id,creation_ts,updater_id,modification_ts,active,is_open,execution_type,
// 1.9 id,tc_external_id,version,summary,importance,author_id,creation_ts,updater_id,modification_ts,active,is_open,execution_type,
//
// 1.9 tcsteps
// id,step_number,actions,expected_results,active,execution_type
//
// NEEDED FIELDS
$sql = " INSERT INTO {$tableSet['tcsteps']} " . " (id,actions,expected_results,active,execution_type) " . " SELECT id,steps,expected_results,active,execution_type " . " FROM {$tableSet['tcversions']}";
$dbHandler->exec_query($sql);
// STEP 2 - Create nodes for tcsteps on nodes_hierarchy table
foreach ($itemSet as $dummy => $item_info) {
// BUGID 4174 - do not show each migrated test case on migration log
//echo "Test Case:" . $item_info['name'] . " Version DBID: {$item_info['id']} <br>";
$item_id = $tree_mgr->new_node($item_info['id'], $node_types_descr_id['testcase_step']);
if ($item_id > 0) {
$sql = " UPDATE {$tableSet['tcsteps']} " . " SET id = {$item_id} WHERE id={$item_info['id']}";
$dbHandler->exec_query($sql);
} else {
echo "<b> **** <br> CRITIC ***** <br>";
echo "MIGRATION FAILURE - Unable to create Test Case Step NODE on nodes hierarchy <br></b>";
}
}
// STEP 3 - Remove fields from tcversions
$sql = "ALTER TABLE {$tableSet['tcversions']} DROP COLUMN steps";
$dbHandler->exec_query($sql);
$sql = "ALTER TABLE {$tableSet['tcversions']} DROP COLUMN expected_results ";
$dbHandler->exec_query($sql);
//.........这里部分代码省略.........
示例2: migrate_testcases
/**
* migrate_testcases
*/
function migrate_testcases(&$dbHandler, $tableSet)
{
// TL 1.8
// --
// -- Table structure for table "tcversions"
// --
// CREATE TABLE "tcversions" (
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES nodes_hierarchy (id),
// "tc_external_id" INT NULL,
// "version" INTEGER NOT NULL DEFAULT '1',
// "summary" TEXT NULL DEFAULT NULL,
// "steps" TEXT NULL DEFAULT NULL,
// "expected_results" TEXT NULL DEFAULT NULL,
// "importance" INT2 NOT NULL DEFAULT '2',
// "author_id" BIGINT NULL DEFAULT NULL REFERENCES users (id),
// "creation_ts" TIMESTAMP NOT NULL DEFAULT now(),
// "updater_id" BIGINT NULL DEFAULT NULL REFERENCES users (id),
// "modification_ts" TIMESTAMP NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "is_open" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
// TL 1.9
// --
// -- Table structure for table "tcversions"
// --
// CREATE TABLE /*prefix*/tcversions(
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/nodes_hierarchy (id),
// "tc_external_id" INT NULL,
// "version" INTEGER NOT NULL DEFAULT '1',
// "layout" INTEGER NOT NULL DEFAULT '1',
// "summary" TEXT NULL DEFAULT NULL,
// "preconditions" TEXT NULL DEFAULT NULL,
// "importance" INT2 NOT NULL DEFAULT '2',
// "author_id" BIGINT NULL DEFAULT NULL REFERENCES /*prefix*/users (id),
// "creation_ts" TIMESTAMP NOT NULL DEFAULT now(),
// "updater_id" BIGINT NULL DEFAULT NULL REFERENCES /*prefix*/users (id),
// "modification_ts" TIMESTAMP NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "is_open" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
//
//
// --
// -- Table structure for table "tcsteps"
// --
// CREATE TABLE /*prefix*/tcsteps (
// "id" BIGINT NOT NULL DEFAULT '0' REFERENCES /*prefix*/nodes_hierarchy (id),
// "step_number" INT NOT NULL DEFAULT '1',
// "actions" TEXT NULL DEFAULT NULL,
// "expected_results" TEXT NULL DEFAULT NULL,
// "active" INT2 NOT NULL DEFAULT '1',
// "execution_type" INT2 NOT NULL DEFAULT '1',
// PRIMARY KEY ("id")
// );
echo __FUNCTION__;
// do test cases exist?
$sql = "SELECT id FROM {$tableSet['tcversions']}";
$itemSet = $dbHandler->get_recordset($sql);
if (!is_null($itemSet) && count($itemSet) > 0) {
$tree_mgr = new tree($dbHandler);
$node_types_descr_id = $tree_mgr->get_available_node_types();
$node_types_id_descr = array_flip($node_types_descr_id);
// STEP 1 - Populate in bulk mode tcsteps table.
//
// ALL FIELDS - tcversions 1.8
// 1.8 id,tc_external_id,version,summary,steps,expected_results,importance,author_id,creation_ts,updater_id,modification_ts,active,is_open,execution_type,
// 1.9 id,tc_external_id,version,summary,importance,author_id,creation_ts,updater_id,modification_ts,active,is_open,execution_type,
//
// 1.9 tcsteps
// id,step_number,actions,expected_results,active,execution_type
//
// NEEDED FIELDS
$sql = " INSERT INTO {$tableSet['tcsteps']} " . " (id,actions,expected_results,active,execution_type) " . " SELECT id,steps,expected_results,active,execution_type " . " FROM {$tableSet['tcversions']}";
$dbHandler->exec_query($sql);
// STEP 2 - Create nodes for tcsteps on nodes_hierarchy table
foreach ($itemSet as $dummy => $item_info) {
$item_id = $tree_mgr->new_node($item_info['id'], $node_types_descr_id['testcase_step']);
$sql = " UPDATE {$tableSet['tcsteps']} " . " SET id = {$item_id} WHERE id={$item_info['id']}";
$dbHandler->exec_query($sql);
}
// STEP 3 - Remove fields from tcversions
$sql = "ALTER TABLE {$tableSet['tcversions']} " . "DROP steps, DROP expected_results ";
$dbHandler->exec_query($sql);
}
}