本文整理汇总了PHP中Repository::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::getInstance方法的具体用法?PHP Repository::getInstance怎么用?PHP Repository::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canShowByType
/**
* Each object type may have its own special rules, and re-implement this function.
*
* @param int $access_level
*
* @return bool
*/
protected function canShowByType($access_level)
{
// Hide sources if they are attached to private repositories ...
preg_match_all('/\\n1 REPO @(.+)@/', $this->gedcom, $matches);
foreach ($matches[1] as $match) {
$repo = Repository::getInstance($match, $this->tree);
if ($repo && !$repo->canShow($access_level)) {
return false;
}
}
// ... otherwise apply default behaviour
return parent::canShowByType($access_level);
}
示例2: get_SOUR_rows
}
}
// Fetch all data, regardless of privacy
$rows = get_SOUR_rows($WT_TREE, $term);
// Filter for privacy
foreach ($rows as $row) {
$source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom);
if ($source->canShowName()) {
$data[] = array('value' => $source->getXref(), 'label' => $source->getFullName());
}
}
// Fetch all data, regardless of privacy
$rows = get_REPO_rows($WT_TREE, $term);
// Filter for privacy
foreach ($rows as $row) {
$repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
if ($repository->canShowName()) {
$data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
}
}
// Fetch all data, regardless of privacy
$rows = get_OBJE_rows($WT_TREE, $term);
// Filter for privacy
foreach ($rows as $row) {
$media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
if ($media->canShowName()) {
$data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
}
}
// Fetch all data, regardless of privacy
$rows = get_FAM_rows($WT_TREE, $term);
示例3: getCategoryInfos
public static function getCategoryInfos()
{
// {{{
$sql = 'select category.category_id, category.category, count(*) as total' . ' from article, category' . ' where article.category_id = category.category_id' . ' group by article.category_id';
$pdo = Repository::getInstance();
$stmt = $pdo->query($sql);
$ret = $stmt->fetchAll();
return $ret;
}
示例4: __construct
if (!isset($options['t'])) {
echo 'usage: php create_model.php' . ' -t table' . PHP_EOL;
exit;
}
$table = $options['t'];
$table_class = ucfirst(StringOpt::unlinetocamel($table) . 'Model');
$file = MODEL_PATH . '/' . $table_class . '.php';
if (file_exists($file)) {
echo '文件已存在,是否替换 [y/N]';
$sure = fgets(STDIN);
if (trim($sure[0]) != 'Y' && trim($sure[0]) != 'y') {
exit;
}
}
$rp = new Repository('db', true);
$pdo = $rp->getInstance();
$sql = 'describe ' . $table;
$rs = $pdo->query($sql);
$model = '<?php' . PHP_EOL . 'class ' . $table_class . PHP_EOL . '{' . PHP_EOL;
$rows = $rs->fetchAll();
foreach ($rows as $row) {
$model .= "\t" . 'private $' . $row['Field'] . ';' . PHP_EOL;
}
$model .= PHP_EOL;
$model .= "\t" . 'public function __construct($params = array())' . PHP_EOL . "\t{" . PHP_EOL . "\t\t" . 'foreach (get_object_vars($this) as $key=>$value)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . 'if ($key != $this->get_pri_key() && isset($params[$key]))' . PHP_EOL . "\t\t\t\t" . '$this->$key = $params[$key];' . PHP_EOL . "\t\t\t" . 'else if (empty($this->$key))' . PHP_EOL . "\t\t\t\t" . '$this->$key = "";' . PHP_EOL . "\t\t}" . PHP_EOL . "\t}" . PHP_EOL . PHP_EOL;
$model .= "\t" . 'public function get_model_fields()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return array_keys(get_object_vars($this));' . PHP_EOL . "\t" . '}' . PHP_EOL;
foreach ($rows as $row) {
$model .= "\t" . 'public function get_' . $row['Field'] . '()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return $this->' . $row['Field'] . ';' . PHP_EOL . "\t" . '}' . PHP_EOL;
if ($row['Key'] != 'PRI') {
$model .= "\t" . 'public function set_' . $row['Field'] . '($value)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . '$this->' . $row['Field'] . ' = $value;' . PHP_EOL . "\t\t" . 'return $this;' . PHP_EOL . "\t" . '}' . PHP_EOL;
} else {
示例5: foreach
return;
}
foreach ($tags as $tag) {
$tag = trim($tag);
if ($tag == '') {
continue;
}
$tag_id = Repository::findTagIdFromTags(array('eq' => array('tag_name' => $tag)));
if ($tag_id == false) {
$tag = new TagsModel(array('tag_name' => $tag, 'inserttime' => 'now()'));
$tag_id = Repository::persist($tag);
if ($tag_id == false) {
LogOpt::set('exception', 'tag 添加失败');
continue;
}
}
$article_tag_relation = new ArticleTagRelationModel(array('article_id' => $article_id, 'tag_id' => $tag_id, 'inserttime' => 'now()'));
try {
$relation_id = Repository::persist($article_tag_relation);
} catch (PDOException $e) {
LogOpt::set('exception', 'article_tag_relation 已存在', 'article_id', $article_id, 'tag_id', $tag_id);
$pdo = Repository::getInstance();
$pdo->rollback();
continue;
}
if ($relation_id == false) {
LogOpt::set('exception', 'article_tag_relation 更新失败', 'article_id', $article_id, 'tag_id', $tag_id);
continue;
}
LogOpt::set('info', 'article_tag_relation 更新成功', 'relation_id', $relation_id);
}
示例6: autocomplete_REPO_NAME
/**
* returns REPO:NAME matching filter
* @return Array of string
*/
function autocomplete_REPO_NAME($FILTER)
{
$rows = get_autocomplete_REPO_NAME($FILTER);
$data = array();
foreach ($rows as $row) {
$repository = Repository::getInstance($row);
if ($repository->canDisplayName()) {
$data[] = $repository->getFullName();
}
}
return $data;
}
示例7: autocomplete_REPO_NAME
/**
* returns REPO:NAME matching filter
* @return Array of string
*/
function autocomplete_REPO_NAME($FILTER)
{
global $TBLPREFIX, $gBitDb;
$sql = "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec" . " FROM {$TBLPREFIX}other" . " WHERE o_gedcom LIKE ? AND o_file=? AND o_type='REPO'";
$rows = $gBitDb->query($sql, array("%1 NAME %{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT);
$data = array();
while ($row = $rows->fetchRows()) {
$repository = Repository::getInstance($row);
if ($repository->canDisplayName()) {
$data[] = $repository->getFullName();
}
}
return $data;
}
示例8: get_repo_list
function get_repo_list($ged_id)
{
global $TBLPREFIX, $gBitDb;
$rows = $gBitDb->GetAssoc("SELECT 'REPO' AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec FROM {$TBLPREFIX}other WHERE o_type='REPO' AND o_file=?", array($ged_id));
$list = array();
foreach ($rows as $row) {
$list[] = Repository::getInstance($row);
}
usort($list, array('GedcomRecord', 'Compare'));
return $list;
}