当前位置: 首页>>代码示例>>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;未经允许,请勿转载。