當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tree::new_node方法代碼示例

本文整理匯總了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);
//.........這裏部分代碼省略.........
開發者ID:moraesmv,項目名稱:testlink-code,代碼行數:101,代碼來源:migrate_18_to_19.php

示例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);
    }
}
開發者ID:viglesiasce,項目名稱:tl_RC1,代碼行數:92,代碼來源:migrate_18_to_19.php


注:本文中的tree::new_node方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。