当前位置: 首页>>代码示例>>PHP>>正文


PHP DoliDB::DDLInfoTable方法代码示例

本文整理汇总了PHP中DoliDB::DDLInfoTable方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::DDLInfoTable方法的具体用法?PHP DoliDB::DDLInfoTable怎么用?PHP DoliDB::DDLInfoTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoliDB的用法示例。


在下文中一共展示了DoliDB::DDLInfoTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: migrate_categorie_association

/**
 * Migrate categorie association
 *
 * @param	DoliDB		$db				Database handler
 * @param	Translate	$langs			Object langs
 * @param	Conf		$conf			Object conf
 * @return	void
 */
function migrate_categorie_association($db, $langs, $conf)
{
    print '<tr><td colspan="4">';
    print '<br>';
    print '<b>' . $langs->trans('MigrationCategorieAssociation') . "</b><br>\n";
    $error = 0;
    if ($db->DDLInfoTable(MAIN_DB_PREFIX . "categorie_association")) {
        dolibarr_install_syslog("upgrade2::migrate_categorie_association");
        $db->begin();
        $sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille";
        $sqlSelect .= " FROM " . MAIN_DB_PREFIX . "categorie_association";
        $resql = $db->query($sqlSelect);
        if ($resql) {
            $i = 0;
            $num = $db->num_rows($resql);
            if ($num) {
                while ($i < $num) {
                    $obj = $db->fetch_object($resql);
                    $sqlUpdate = "UPDATE " . MAIN_DB_PREFIX . "categorie SET ";
                    $sqlUpdate .= "fk_parent = " . $obj->fk_categorie_mere;
                    $sqlUpdate .= " WHERE rowid = " . $obj->fk_categorie_fille;
                    $result = $db->query($sqlUpdate);
                    if (!$result) {
                        $error++;
                        dol_print_error($db);
                    }
                    print ". ";
                    $i++;
                }
            } else {
                print $langs->trans('AlreadyDone') . "<br>\n";
            }
            if (!$error) {
                // TODO DROP table in the next release
                /*
                $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association";
                if ($db->query($sqlDrop))
                {
                	$db->commit();
                }
                else
                {
                	$db->rollback();
                }
                */
                $db->commit();
            } else {
                $db->rollback();
            }
        } else {
            dol_print_error($db);
            $db->rollback();
        }
    } else {
        print $langs->trans('AlreadyDone') . "<br>\n";
    }
    print '</td></tr>';
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:66,代码来源:upgrade2.php

示例2: migrate_relationship_tables

/**
 * Migration des tables de relation
 *
 * @param	DoliDB		$db				Database handler
 * @param	Translate	$langs			Object langs
 * @param	Conf		$conf			Object conf
 * @param	string		$table			Table name
 * @param	int			$fk_source		Id of element source
 * @param	type		$sourcetype		Type of element source
 * @param	int			$fk_target		Id of element target
 * @param	type		$targettype		Type of element target
 * @return	void
 */
function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcetype,$fk_target,$targettype)
{
    print '<tr><td colspan="4">';

    print '<br>';
    print '<b>'.$langs->trans('MigrationRelationshipTables',MAIN_DB_PREFIX.$table)."</b><br>\n";

    $error = 0;

    if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table))
    {
        dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table);

        $db->begin();

        $sqlSelect = "SELECT ".$fk_source.", ".$fk_target;
        $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table;

        $resql = $db->query($sqlSelect);
        if ($resql)
        {
            $i = 0;
            $num = $db->num_rows($resql);

            if ($num)
            {
                while ($i < $num)
                {
                    $obj = $db->fetch_object($resql);

                    $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
                    $sqlInsert.= "fk_source";
                    $sqlInsert.= ", sourcetype";
                    $sqlInsert.= ", fk_target";
                    $sqlInsert.= ", targettype";
                    $sqlInsert.= ") VALUES (";
                    $sqlInsert.= $obj->$fk_source;
                    $sqlInsert.= ", '".$sourcetype."'";
                    $sqlInsert.= ", ".$obj->$fk_target;
                    $sqlInsert.= ", '".$targettype."'";
                    $sqlInsert.= ")";

                    $result=$db->query($sqlInsert);
                    if (! $result)
                    {
                        $error++;
                        dol_print_error($db);
                    }
                    print ". ";
                    $i++;
                }
            }
            else
            {
                print $langs->trans('AlreadyDone')."<br>\n";
            }

            if ($error == 0)
            {
                $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX.$table;
                if ($db->query($sqlDrop))
                {
                    $db->commit();
                }
                else
                {
                    $db->rollback();
                }
            }
            else
            {
                $db->rollback();
            }
        }
        else
        {
            dol_print_error($db);
            $db->rollback();
        }
    }
    else
    {
        print $langs->trans('AlreadyDone')."<br>\n";
    }

    print '</td></tr>';
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:100,代码来源:upgrade2.php


注:本文中的DoliDB::DDLInfoTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。