本文整理汇总了PHP中Fisharebest\Webtrees\Tree::FindById方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::FindById方法的具体用法?PHP Tree::FindById怎么用?PHP Tree::FindById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Tree
的用法示例。
在下文中一共展示了Tree::FindById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateRecord
/**
* update a record in the database
*
* @param string $gedrec
* @param int $ged_id
* @param bool $delete
*/
public static function updateRecord($gedrec, $ged_id, $delete)
{
if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedrec, $match)) {
list(, $gid, $type) = $match;
} else {
echo "ERROR: Invalid gedcom record.";
return;
}
// TODO deleting unlinked places can be done more efficiently in a single query
$placeids = Database::prepare("SELECT pl_p_id FROM `##placelinks` WHERE pl_gid=? AND pl_file=?")->execute(array($gid, $ged_id))->fetchOneColumn();
Database::prepare("DELETE FROM `##placelinks` WHERE pl_gid=? AND pl_file=?")->execute(array($gid, $ged_id));
Database::prepare("DELETE FROM `##dates` WHERE d_gid =? AND d_file =?")->execute(array($gid, $ged_id));
//-- delete any unlinked places
foreach ($placeids as $p_id) {
$num = Database::prepare("SELECT count(pl_p_id) FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($p_id, $ged_id))->fetchOne();
if ($num == 0) {
Database::prepare("DELETE FROM `##places` WHERE p_id=? AND p_file=?")->execute(array($p_id, $ged_id));
}
}
Database::prepare("DELETE FROM `##name` WHERE n_id=? AND n_file=?")->execute(array($gid, $ged_id));
Database::prepare("DELETE FROM `##link` WHERE l_from=? AND l_file=?")->execute(array($gid, $ged_id));
switch ($type) {
case 'INDI':
Database::prepare("DELETE FROM `##individuals` WHERE i_id=? AND i_file=?")->execute(array($gid, $ged_id));
break;
case 'FAM':
Database::prepare("DELETE FROM `##families` WHERE f_id=? AND f_file=?")->execute(array($gid, $ged_id));
break;
case 'SOUR':
Database::prepare("DELETE FROM `##sources` WHERE s_id=? AND s_file=?")->execute(array($gid, $ged_id));
break;
case 'OBJE':
Database::prepare("DELETE FROM `##media` WHERE m_id=? AND m_file=?")->execute(array($gid, $ged_id));
break;
default:
Database::prepare("DELETE FROM `##other` WHERE o_id=? AND o_file=?")->execute(array($gid, $ged_id));
break;
}
if (!$delete) {
self::importRecord($gedrec, Tree::FindById($ged_id), true);
}
}