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


PHP Database::quote方法代码示例

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


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

示例1: givenAlpha

 /**
  * Get a list of initial given name letters for indilist.php and famlist.php
  *
  * @param Tree   $tree   Find names in this tree
  * @param string $surn   if set, only consider people with this surname
  * @param string $salpha if set, only consider surnames starting with this letter
  * @param bool   $marnm  if set, include married names
  * @param bool   $fams   if set, only consider individuals with FAMS records
  *
  * @return int[]
  */
 public static function givenAlpha(Tree $tree, $surn, $salpha, $marnm, $fams)
 {
     $alphas = array();
     $sql = "SELECT SQL_CACHE COUNT(DISTINCT n_id)" . " FROM `##name`" . ($fams ? " JOIN `##link` ON (n_id=l_from AND n_file=l_file AND l_type='FAMS') " : "") . " WHERE n_file=" . $tree->getTreeId() . " " . ($marnm ? "" : " AND n_type!='_MARNM'");
     if ($surn) {
         $sql .= " AND n_surn=" . Database::quote($surn) . " COLLATE '" . I18N::collation() . "'";
     } 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.')";
     }
     // Fetch all the letters in our alphabet, whether or not there
     // are any names beginning with that letter. It looks better to
     // show the full alphabet, rather than omitting rare letters such as X
     foreach (self::getAlphabetForLocale(WT_LOCALE) as $letter) {
         $count = Database::prepare($sql . " AND " . self::getInitialSql('n_givn', $letter))->fetchOne();
         $alphas[$letter] = $count;
     }
     // Now fetch initial letters that are not in our alphabet,
     // including "@" (for "@N.N.") and "" for no surname
     $sql = "SELECT SQL_CACHE initial, total FROM (SELECT UPPER(LEFT(n_givn, 1)) AS initial, COUNT(DISTINCT n_id) AS total" . " FROM `##name` " . ($fams ? " JOIN `##link` ON (n_id = l_from AND n_file = l_file AND l_type = 'FAMS') " : "") . " WHERE n_file = :tree_id" . ($marnm ? "" : " AND n_type != '_MARNM'");
     $args = array('tree_id' => $tree->getTreeId());
     if ($surn) {
         $sql .= " AND n_surn COLLATE :collate_1 = :surn";
         $args['collate_1'] = I18N::collation();
         $args['surn'] = $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.')";
     }
     foreach (self::getAlphabetForLocale(WT_LOCALE) as $letter) {
         $sql .= " AND n_givn NOT LIKE '" . $letter . "%' COLLATE " . I18N::collation();
     }
     $sql .= " GROUP BY UPPER(LEFT(n_givn, 1))) AS subquery ORDER BY initial = '@', initial = '', initial";
     foreach (Database::prepare($sql)->execute($args)->fetchAssoc() as $alpha => $count) {
         $alphas[$alpha] = $count;
     }
     return $alphas;
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:61,代码来源:QueryName.php


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