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


PHP WT_DB类代码示例

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


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

示例1: import_gedcom_file

function import_gedcom_file($gedcom_id, $path, $filename)
{
    // Read the file in blocks of roughly 64K.  Ensure that each block
    // contains complete gedcom records.  This will ensure we don’t split
    // multi-byte characters, as well as simplifying the code to import
    // each block.
    $file_data = '';
    $fp = fopen($path, 'rb');
    WT_DB::exec("START TRANSACTION");
    WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id=?")->execute(array($gedcom_id));
    while (!feof($fp)) {
        $file_data .= fread($fp, 65536);
        // There is no strrpos() function that searches for substrings :-(
        for ($pos = strlen($file_data) - 1; $pos > 0; --$pos) {
            if ($file_data[$pos] == '0' && ($file_data[$pos - 1] == "\n" || $file_data[$pos - 1] == "\r")) {
                // We’ve found the last record boundary in this chunk of data
                break;
            }
        }
        if ($pos) {
            WT_DB::prepare("INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)")->execute(array($gedcom_id, substr($file_data, 0, $pos)));
            $file_data = substr($file_data, $pos);
        }
    }
    WT_DB::prepare("INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)")->execute(array($gedcom_id, $file_data));
    set_gedcom_setting($gedcom_id, 'gedcom_filename', $filename);
    WT_DB::exec("COMMIT");
    fclose($fp);
}
开发者ID:brambravo,项目名称:webtrees,代码行数:29,代码来源:admin_trees_manage.php

示例2: loadIndividuals

 private function loadIndividuals()
 {
     $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . " FROM `##individuals`" . " JOIN `##name` ON (i_id=n_id AND i_file=n_file)" . " WHERE n_file=?" . " AND n_type!=?" . " AND (n_surn=? OR n_surname=?";
     $args = array(WT_GED_ID, '_MARNM', $this->surname, $this->surname);
     if ($this->soundex_std) {
         $sdx = WT_Soundex::soundex_std($this->surname);
         if ($sdx) {
             foreach (explode(':', $sdx) as $value) {
                 $sql .= " OR n_soundex_surn_std LIKE CONCAT('%', ?, '%')";
                 $args[] = $value;
             }
         }
     }
     if ($this->soundex_dm) {
         $sdx = WT_Soundex::soundex_dm($this->surname);
         if ($sdx) {
             foreach (explode(':', $sdx) as $value) {
                 $sql .= " OR n_soundex_surn_dm LIKE CONCAT('%', ?, '%')";
                 $args[] = $value;
             }
         }
     }
     $sql .= ')';
     $rows = WT_DB::prepare($sql)->execute($args)->fetchAll();
     $this->individuals = array();
     foreach ($rows as $row) {
         $this->individuals[] = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
     }
     // Sort by birth date, oldest first
     usort($this->individuals, array('WT_Individual', 'CompareBirtDate'));
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:Branches.php

示例3: fetchGedcomRecord

 protected static function fetchGedcomRecord($xref, $gedcom_id)
 {
     static $statement = null;
     if ($statement === null) {
         $statement = WT_DB::prepare("SELECT m_gedcom FROM `##media` WHERE m_id=? AND m_file=?");
     }
     return $statement->execute(array($xref, $gedcom_id))->fetchOne();
 }
开发者ID:sadr110,项目名称:webtrees,代码行数:8,代码来源:Media.php

示例4: fetchGedcomRecord

 protected static function fetchGedcomRecord($xref, $gedcom_id)
 {
     static $statement = null;
     if ($statement === null) {
         $statement = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_id=? AND o_file=? AND o_type='NOTE'");
     }
     return $statement->execute(array($xref, $gedcom_id))->fetchOne();
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:8,代码来源:Note.php

示例5: setPreference

 /**
  * Set the site’s configuration settings.
  *
  * @param string          $setting_name
  * @param string|int|bool $setting_value
  *
  * @return void
  */
 public static function setPreference($setting_name, $setting_value)
 {
     // Only need to update the database if the setting has actually changed.
     if (self::getPreference($setting_name) != $setting_value) {
         WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value));
         self::$setting[$setting_name] = $setting_value;
         Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"');
     }
 }
开发者ID:jacoline,项目名称:webtrees,代码行数:17,代码来源:Site.php

示例6: getBlock

 public function getBlock($block_id, $template = true, $cfg = null)
 {
     global $ctype, $SHOW_COUNTER;
     $count_placement = get_block_setting($block_id, 'count_placement', 'before');
     $num = (int) get_block_setting($block_id, 'num', 10);
     $block = get_block_setting($block_id, 'block', false);
     if ($cfg) {
         foreach (array('count_placement', 'num', 'block') as $name) {
             if (array_key_exists($name, $cfg)) {
                 ${$name} = $cfg[$name];
             }
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
         $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle();
     $content = "";
     // load the lines from the file
     $top10 = WT_DB::prepare("SELECT page_parameter, page_count" . " FROM `##hit_counter`" . " WHERE gedcom_id=? AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT " . $num)->execute(array(WT_GED_ID))->FetchAssoc();
     if ($block) {
         $content .= "<table width=\"90%\">";
     } else {
         $content .= "<table>";
     }
     foreach ($top10 as $id => $count) {
         $record = WT_GedcomRecord::getInstance($id);
         if ($record && $record->canShow()) {
             $content .= '<tr valign="top">';
             if ($count_placement == 'before') {
                 $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
             }
             $content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
             if ($count_placement == 'after') {
                 $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
             }
             $content .= '</tr>';
         }
     }
     $content .= "</table>";
     if ($template) {
         if ($block) {
             require WT_THEME_DIR . 'templates/block_small_temp.php';
         } else {
             require WT_THEME_DIR . 'templates/block_main_temp.php';
         }
     } else {
         return $content;
     }
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:54,代码来源:module.php

示例7: execute

 /**
  * Execute a query
  *
  * @param array $bind_variables
  *
  * @return WT_DBStatement
  * @throws Exception
  */
 public function execute($bind_variables = array())
 {
     if ($this->executed) {
         throw new Exception('WT_DBStatement::execute() called twice.');
     }
     // Turn booleans into integers.  Otherwise MySQL’s strict mode can get upset.
     foreach ($bind_variables as &$bind_variable) {
         if ($bind_variable === false) {
             // Otherwise true=>'1' and false=>''
             $bind_variable = 0;
         }
     }
     $start = microtime(true);
     $this->pdo_statement->execute($bind_variables);
     $end = microtime(true);
     // If it was a SELECT statement, we cannot run it again.
     $this->executed = strpos($this->pdo_statement->queryString, 'SELECT') === 0;
     WT_DB::logQuery($this->pdo_statement->queryString, $this->pdo_statement->rowCount(), $end - $start, $bind_variables);
     return $this;
 }
开发者ID:jacoline,项目名称:webtrees,代码行数:28,代码来源:DBStatement.php

示例8: preference

 public static function preference($setting_name, $setting_value = null)
 {
     // There are lots of settings, and we need to fetch lots of them on every page
     // so it is quicker to fetch them all in one go.
     if (self::$setting === null) {
         self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc();
     }
     // If $setting_value is null, then GET the setting
     if ($setting_value === null) {
         // If parameter two is not specified, GET the setting
         if (!array_key_exists($setting_name, self::$setting)) {
             self::$setting[$setting_name] = null;
         }
         return self::$setting[$setting_name];
     } else {
         // If parameter two is specified, then SET the setting
         if (self::preference($setting_name) != $setting_value) {
             // Audit log of changes
             Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"');
         }
         WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value));
         self::$setting[$setting_name] = $setting_value;
     }
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:24,代码来源:Site.php

示例9: individuals

 /**
  * Fetch a list of individuals with specified names
  *
  * To search for unknown names, use $surn="@N.N.", $salpha="@" or $galpha="@"
  * To search for names with no surnames, use $salpha=","
  *
  * @param string $surn   if set, only fetch people with this surname
  * @param string $salpha if set, only fetch surnames starting with this letter
  * @param string $galpha if set, only fetch given names starting with this letter
  * @param bool   $marnm  if set, include married names
  * @param bool   $fams   if set, only fetch individuals with FAMS records
  * @param int    $ged_id if set, only fetch individuals from this gedcom
  *
  * @return WT_Individual[]
  */
 public static function individuals($surn, $salpha, $galpha, $marnm, $fams, $ged_id)
 {
     $sql = "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, n_full " . "FROM `##individuals` " . "JOIN `##name` ON (n_id=i_id AND n_file=i_file) " . ($fams ? "JOIN `##link` ON (n_id=l_from AND n_file=l_file AND l_type='FAMS') " : "") . "WHERE n_file={$ged_id} " . ($marnm ? "" : "AND n_type!='_MARNM'");
     if ($surn) {
         $sql .= " AND n_surn COLLATE '" . WT_I18N::$collation . "'=" . WT_DB::quote($surn);
     } elseif ($salpha == ',') {
         $sql .= " AND n_surn=''";
     } elseif ($salpha == '@') {
         $sql .= " AND n_surn='@N.N.'";
     } elseif ($salpha) {
         $sql .= " AND " . self::_getInitialSql('n_surn', $salpha);
     } else {
         // All surnames
         $sql .= " AND n_surn NOT IN ('', '@N.N.')";
     }
     if ($galpha) {
         $sql .= " AND " . self::_getInitialSql('n_givn', $galpha);
     }
     $sql .= " ORDER BY CASE n_surn WHEN '@N.N.' THEN 1 ELSE 0 END, n_surn COLLATE '" . WT_I18N::$collation . "', CASE n_givn WHEN '@P.N.' THEN 1 ELSE 0 END, n_givn COLLATE '" . WT_I18N::$collation . "'";
     $list = array();
     $rows = WT_DB::prepare($sql)->fetchAll();
     foreach ($rows as $row) {
         $person = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
         // The name from the database may be private - check the filtered list...
         foreach ($person->getAllNames() as $n => $name) {
             if ($name['fullNN'] == $row->n_full) {
                 $person->setPrimaryName($n);
                 // We need to clone $person, as we may have multiple references to the
                 // same person in this list, and the "primary name" would otherwise
                 // be shared amongst all of them.
                 $list[] = clone $person;
                 break;
             }
         }
     }
     return $list;
 }
开发者ID:sadr110,项目名称:webtrees,代码行数:52,代码来源:Name.php

示例10: getSignificantIndividual

 public function getSignificantIndividual()
 {
     static $individual;
     // Only query the DB once.
     if (!$individual && WT_USER_ROOT_ID) {
         $individual = WT_Individual::getInstance(WT_USER_ROOT_ID);
     }
     if (!$individual && WT_USER_GEDCOM_ID) {
         $individual = WT_Individual::getInstance(WT_USER_GEDCOM_ID);
     }
     if (!$individual) {
         $individual = WT_Individual::getInstance(get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID'));
     }
     if (!$individual) {
         $individual = WT_Individual::getInstance(WT_DB::prepare("SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?")->execute(array(WT_GED_ID))->fetchOne());
     }
     if (!$individual) {
         // always return a record
         $individual = new WT_Individual('I', '0 @I@ INDI', null, WT_GED_ID);
     }
     return $individual;
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:22,代码来源:Page.php

示例11: foreach

    echo $module->getDescription();
    ?>
</td>
						<td><input type="text" size="3" value="<?php 
    echo $order;
    ?>
" name="sidebarorder-<?php 
    echo $module->getName();
    ?>
"></td>
						<td>
							<table class="modules_table2">
								<?php 
    foreach (WT_Tree::getAll() as $tree) {
        $varname = 'sidebaraccess-' . $module_name . '-' . $tree->tree_id;
        $access_level = WT_DB::prepare("SELECT access_level FROM `##module_privacy` WHERE gedcom_id=? AND module_name=? AND component='sidebar'")->execute(array($tree->tree_id, $module_name))->fetchOne();
        if ($access_level === null) {
            $access_level = $module->defaultAccessLevel();
        }
        echo '<tr><td>', $tree->tree_title_html, '</td><td>';
        echo edit_field_access_level($varname, $access_level);
    }
    ?>
							</table>
						</td>
					</tr>
				<?php 
    $order++;
}
?>
			</tbody>
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:admin_module_sidebar.php

示例12: update_favorites

function update_favorites($xref_from, $xref_to, $ged_id = WT_GED_ID)
{
    return WT_DB::prepare("UPDATE `##favorite` SET xref=? WHERE xref=? AND gedcom_id=?")->execute(array($xref_to, $xref_from, $ged_id))->rowCount();
}
开发者ID:jacoline,项目名称:webtrees,代码行数:4,代码来源:functions_db.php

示例13: header

// It shouldn't do anything that might take more than a few
// seconds, for systems with low timeout values.
//
// webtrees: Web based Family History software
// Copyright (C) 2014 Greg Roach
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
if (!defined('WT_WEBTREES')) {
    header('HTTP/1.0 403 Forbidden');
    exit;
}
// Create all of the tables needed for this module
try {
    WT_DB::exec("ALTER TABLE `##placelocation` ADD (" . " pl_media      VARCHAR(60)     NULL," . " sv_long       FLOAT           NOT NULL DEFAULT 0," . " sv_lati       FLOAT           NOT NULL DEFAULT 0," . " sv_bearing    FLOAT           NOT NULL DEFAULT 0," . " sv_elevation  FLOAT           NOT NULL DEFAULT 0," . " sv_zoom       FLOAT           NOT NULL DEFAULT 1" . ")");
} catch (PDOException $ex) {
    // Already done this?
}
// Update the version to indicate success
WT_Site::preference($schema_name, $next_version);
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:db_schema_1_2.php

示例14: header

//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
if (!defined('WT_WEBTREES')) {
    header('HTTP/1.0 403 Forbidden');
    exit;
}
// Create tables, if not already present
try {
    WT_DB::updateSchema(WT_MODULES_DIR, 'user_blog/db_schema/', 'NB_SCHEMA_VERSION', 3);
} catch (PDOException $ex) {
    // The schema update scripts should never fail.  If they do, there is no clean recovery.
    die($ex);
}
class user_blog_WT_Module extends WT_Module implements WT_Module_Block
{
    // Extend class WT_Module
    public function getTitle()
    {
        return WT_I18N::translate('Journal');
    }
    // Extend class WT_Module
    public function getDescription()
    {
        return WT_I18N::translate('A private area to record notes or keep a journal.');
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:module.php

示例15: ajaxRequest

 public function ajaxRequest()
 {
     global $SEARCH_SPIDER;
     // Search engines should not make AJAX requests
     if ($SEARCH_SPIDER) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
         exit;
     }
     // Initialise tabs
     $tab = WT_Filter::get('module');
     // A request for a non-existant tab?
     if (array_key_exists($tab, $this->tabs)) {
         $mod = $this->tabs[$tab];
     } else {
         header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
         exit;
     }
     header("Content-Type: text/html; charset=UTF-8");
     // AJAX calls do not have the meta tag headers and need this set
     header("X-Robots-Tag: noindex,follow");
     // AJAX pages should not show up in search results, any links can be followed though
     Zend_Session::writeClose();
     echo $mod->getTabContent();
     if (WT_DEBUG_SQL) {
         echo WT_DB::getQueryLog();
     }
 }
开发者ID:jacoline,项目名称:webtrees,代码行数:27,代码来源:Individual.php


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