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


PHP WT_DB::query方法代碼示例

本文整理匯總了PHP中WT_DB::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP WT_DB::query方法的具體用法?PHP WT_DB::query怎麽用?PHP WT_DB::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WT_DB的用法示例。


在下文中一共展示了WT_DB::query方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: COUNT

if ($dbname_ok) {
    try {
        // PhpGedView (4.2.3 and earlier) and many other applications have a USERS table.
        // webtrees has a USER table
        $dummy = WT_DB::query("SELECT COUNT(*) FROM `##users`")->fetchOne();
        echo '<p class="bad">', WT_I18N::translate('This database and table-prefix appear to be used by another application.  If you have an existing PhpGedView system, you should create a new webtrees system.  You can import your PhpGedView data and settings later.'), '</p>';
        $dbname_ok = false;
    } catch (PDOException $ex) {
        // Table not found?  Good!
    }
}
if ($dbname_ok) {
    try {
        // PhpGedView (4.2.4 and later) has a site_setting.site_setting_name column.
        // [We changed the column name in webtrees, so we can tell the difference!]
        $dummy = WT_DB::query("SELECT site_setting_value FROM `##site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'")->fetchOne();
        echo '<p class="bad">', WT_I18N::translate('This database and table-prefix appear to be used by another application.  If you have an existing PhpGedView system, you should create a new webtrees system.  You can import your PhpGedView data and settings later.'), '</p>';
        $dbname_ok = false;
    } catch (PDOException $ex) {
        // Table/column not found?  Good!
    }
}
if (!$dbname_ok) {
    echo '<h2>', WT_I18N::translate('Database and table names'), '</h2>', '<p>', WT_I18N::translate('A database server can store many separate databases.  You need to select an existing database (created by your server’s administrator) or create a new one (if your database user account has sufficient privileges).'), '</p>', '<fieldset><legend>', WT_I18N::translate('Database name'), '</legend>', '<table border="0"><tr><td>', WT_I18N::translate('Database name'), '</td><td>', '<input type="text" name="dbname" value="', WT_Filter::escapeHtml($_POST['dbname']), '" autofocus></td><td>', WT_I18N::translate('This is case sensitive. If a database with this name does not already exist webtrees will attempt to create one for you. Success will depend on permissions set for your web server, but you will be notified if this fails.'), '</td></tr><tr><td>', WT_I18N::translate('Table prefix'), '</td><td>', '<input type="text" name="tblpfx" value="', WT_Filter::escapeHtml($_POST['tblpfx']), '"></td><td>', WT_I18N::translate('The prefix is optional, but recommended.  By giving the table names a unique prefix you can let several different applications share the same database. “wt_” is suggested, but can be anything you want.'), '</td></tr></table>', '</fieldset>', '<br><hr><input type="submit" id="btncontinue" value="', WT_I18N::translate('continue'), '">', '</form>', '</body></html>';
    exit;
} else {
    // Copy these values through to the next step
    echo '<input type="hidden" name="dbname" value="', WT_Filter::escapeHtml($_POST['dbname']), '">';
    echo '<input type="hidden" name="tblpfx" value="', WT_Filter::escapeHtml($_POST['tblpfx']), '">';
}
////////////////////////////////////////////////////////////////////////////////
開發者ID:brambravo,項目名稱:webtrees,代碼行數:31,代碼來源:setup.php


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