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


PHP WT_DB::prepare方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例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: 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

示例8: 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

示例9: define

    define('WT_USER_GEDCOM_ID', '');
    define('WT_USER_ROOT_ID', '');
    define('WT_USER_PATH_LENGTH', 0);
    define('WT_USER_ACCESS_LEVEL', WT_PRIV_PUBLIC);
}
$GEDCOM = WT_GEDCOM;
// With no parameters, init() looks to the environment to choose a language
define('WT_LOCALE', WT_I18N::init());
$WT_SESSION->locale = WT_I18N::$locale;
// Set our gedcom selection as a default for the next page
$WT_SESSION->GEDCOM = WT_GEDCOM;
if (empty($WEBTREES_EMAIL)) {
    $WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', $_SERVER['SERVER_NAME']);
}
// Note that the database/webservers may not be synchronised, so use DB time throughout.
define('WT_TIMESTAMP', (int) WT_DB::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne());
// Server timezone is defined in php.ini
define('WT_SERVER_TIMESTAMP', WT_TIMESTAMP + (int) date('Z'));
if (WT_USER_ID) {
    define('WT_CLIENT_TIMESTAMP', WT_TIMESTAMP - $WT_SESSION->timediff);
} else {
    define('WT_CLIENT_TIMESTAMP', WT_SERVER_TIMESTAMP);
}
define('WT_CLIENT_JD', 2440588 + (int) (WT_CLIENT_TIMESTAMP / 86400));
// Application configuration data - things that aren’t (yet?) user-editable
require WT_ROOT . 'includes/config_data.php';
// The login URL must be an absolute URL, and can be user-defined
if (WT_Site::preference('LOGIN_URL')) {
    define('WT_LOGIN_URL', WT_Site::preference('LOGIN_URL'));
} else {
    define('WT_LOGIN_URL', WT_SERVER_NAME . WT_SCRIPT_PATH . 'login.php');
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:session.php

示例10: all_media_files

function all_media_files($media_folder, $media_path, $subfolders, $filter)
{
    return WT_DB::prepare("SELECT SQL_CACHE SQL_CALC_FOUND_ROWS TRIM(LEADING ? FROM m_filename) AS media_path, 'OBJE' AS type, m_titl, m_id AS xref, m_file AS ged_id, m_gedcom AS gedrec, m_filename" . " FROM  `##media`" . " JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" . " JOIN  `##gedcom`         USING (gedcom_id)" . " WHERE setting_value=?" . " AND   m_filename LIKE CONCAT(?, '%')" . " AND   (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', ?, '%')" . "  OR   m_titl LIKE CONCAT('%', ?, '%'))" . "\tAND   m_filename NOT LIKE 'http://%'" . " AND   m_filename NOT LIKE 'https://%'")->execute(array($media_path, $media_folder, WT_Filter::escapeLike($media_path), WT_Filter::escapeLike($filter), WT_Filter::escapeLike($filter)))->fetchOneColumn();
}
开发者ID:brambravo,项目名称:webtrees,代码行数:4,代码来源:admin_media.php

示例11: getFavorites

 public static function getFavorites($gedcom_id)
 {
     self::updateSchema();
     // make sure the favorites table has been created
     return WT_DB::prepare("SELECT SQL_CACHE favorite_id AS id, user_id, gedcom_id, xref AS gid, favorite_type AS type, title, note, url" . " FROM `##favorite` WHERE gedcom_id=? AND user_id IS NULL")->execute(array($gedcom_id))->fetchAll(PDO::FETCH_ASSOC);
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:6,代码来源:module.php

示例12: 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

示例13: show_list

    private function show_list()
    {
        global $controller;
        $controller = new WT_Controller_Page();
        $controller->setPageTitle($this->getTitle())->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript('
				jQuery("#story_table").dataTable({
					dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
					' . WT_I18N::datatablesI18N() . ',
					autoWidth: false,
					paging: true,
					pagingType: "full_numbers",
					lengthChange: true,
					filter: true,
					info: true,
					jQueryUI: true,
					sorting: [[0,"asc"]],
					columns: [
						/* 0-name */ null,
						/* 1-NAME */ null
					]
				});
			');
        $stories = WT_DB::prepare("SELECT block_id, xref" . " FROM `##block` b" . " WHERE module_name=?" . " AND gedcom_id=?" . " ORDER BY xref")->execute(array($this->getName(), WT_GED_ID))->fetchAll();
        echo '<h2 class="center">', WT_I18N::translate('Stories'), '</h2>';
        if (count($stories) > 0) {
            echo '<table id="story_table" class="width100">';
            echo '<thead><tr>
				<th>', WT_I18N::translate('Story title'), '</th>
				<th>', WT_I18N::translate('Individual'), '</th>
				</tr></thead>
				<tbody>';
            foreach ($stories as $story) {
                $indi = WT_Individual::getInstance($story->xref);
                $story_title = get_block_setting($story->block_id, 'title');
                $languages = get_block_setting($story->block_id, 'languages');
                if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
                    if ($indi) {
                        if ($indi->canShow()) {
                            echo '<tr><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $story_title . '</a></td><td><a href="' . $indi->getHtmlUrl() . '#stories">' . $indi->getFullName() . '</a></td></tr>';
                        }
                    } else {
                        echo '<tr><td>', $story_title, '</td><td class="error">', $story->xref, '</td></tr>';
                    }
                }
            }
            echo '</tbody></table>';
        }
    }
开发者ID:brambravo,项目名称:webtrees,代码行数:48,代码来源:module.php

示例14: VALUES

                // existing block moved location
                WT_DB::prepare("UPDATE `##block` SET location=? WHERE block_id=?")->execute(array($location, $block_name));
            } else {
                // new block
                if ($user_id) {
                    WT_DB::prepare("INSERT INTO `##block` (user_id, location, block_order, module_name) VALUES (?, ?, ?, ?)")->execute(array($user_id, $location, $order, $block_name));
                } else {
                    WT_DB::prepare("INSERT INTO `##block` (gedcom_id, location, block_order, module_name) VALUES (?, ?, ?, ?)")->execute(array($gedcom_id, $location, $order, $block_name));
                }
            }
        }
        // deleted blocks
        foreach ($blocks[$location] as $block_id => $block_name) {
            if (!in_array($block_id, $main) && !in_array($block_id, $right)) {
                WT_DB::prepare("DELETE FROM `##block_setting` WHERE block_id=?")->execute(array($block_id));
                WT_DB::prepare("DELETE FROM `##block`         WHERE block_id=?")->execute(array($block_id));
            }
        }
    }
    exit;
}
$controller->pageHeader()->addInlineJavascript('
	/**
	 * Move Up Block Javascript function
	 *
	 * This function moves the selected option up in the given select list
	 *
	 * @param String section_name the name of the select to move the options
	 */
	function move_up_block(section_name) {
		section_select = document.getElementById(section_name);
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:index_edit.php

示例15: foreach

                    case 'desc':
                        $ORDER_BY .= 1 + $order[$i]['column'] . ' DESC ';
                        break;
                }
            }
        } else {
            $ORDER_BY = '1 ASC';
        }
        // This becomes a JSON list, not array, so need to fetch with numeric keys.
        $data = WT_DB::prepare($SELECT1 . $WHERE . $ORDER_BY . $LIMIT)->execute($args)->fetchAll(PDO::FETCH_NUM);
        foreach ($data as &$datum) {
            $datum[2] = WT_Filter::escapeHtml($datum[2]);
        }
        // Total filtered/unfiltered rows
        $recordsFiltered = WT_DB::prepare("SELECT FOUND_ROWS()")->fetchColumn();
        $recordsTotal = WT_DB::prepare($SELECT2 . $WHERE)->execute($args)->fetchColumn();
        header('Content-type: application/json');
        echo json_encode(array('sEcho' => WT_Filter::getInteger('sEcho'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
        exit;
}
$controller->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript('
		jQuery("#log_list").dataTable( {
			dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
			processing: true,
			serverSide: true,
			ajax: "' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?action=load_json&from=' . $from . '&to=' . $to . '&type=' . $type . '&text=' . rawurlencode($text) . '&ip=' . rawurlencode($ip) . '&user=' . rawurlencode($user) . '&gedc=' . rawurlencode($gedc) . '",
			' . WT_I18N::datatablesI18N(array(10, 20, 50, 100, 500, 1000, -1)) . ',
			jQueryUI: true,
			autoWidth: false,
			sorting: [[ 0, "desc" ]],
			pageLength: ' . Auth::user()->getSetting('admin_site_log_page_size', 20) . ',
开发者ID:brambravo,项目名称:webtrees,代码行数:31,代码来源:admin_site_logs.php


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