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


PHP TagPeer::retrieveOrCreateByTagname方法代码示例

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


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

示例1: array

$t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns:key') === array('ns:key', null, null, null), 'ns:key is not a triple.');
$t->ok(deppPropelActAsTaggableToolkit::extractTriple('ns') === array('ns', null, null, null), 'ns is not a triple.');
$object = _create_object();
$object->addTag('tutu');
$object->save();
$object = _create_object();
$object->addTag('ns:key=value');
$object->addTag('ns:key=tutu');
$object->addTag('ns:key=titi');
$object->addTag('ns:key=toto');
$object->save();
$object_tags = $object->getTags();
$t->ok($object->hasTag('ns:key=value'), 'object has triple tag');
$tag = TagPeer::retrieveOrCreateByTagname('ns:key=value');
$t->ok($tag->getIsTriple(), 'a triple tag created from a string is identified as a triple.');
$tag = TagPeer::retrieveOrCreateByTagname('tutu');
$t->ok(!$tag->getIsTriple(), 'a non tripled tag created from a string is not identified as a triple.');
// these tests check the retrieval of the tags of one object, based on
// triple-tags constraints
$t->diag('retrieving triple tags, and extracting only parts of it');
$object = _create_object();
$object->addTag('geo:lat=50.7');
$object->addTag('geo:long=6.1');
$object->addTag('de:city=Aachen');
$object->addTag('fr:city=Aix la Chapelle');
$object->addTag('en:city=Aix Chapel');
$object->save();
// get all the tags
$tags = $object->getTags();
$t->ok(count($tags) == 5, 'The addTags() method permits to create triple tags, that can be retrieved using getTags().');
$id = $object->getPrimaryKey();
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:deppPropelActAsTaggableBehaviorTest.php

示例2: define

define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$c = new Criteria();
$teseo_tags = OppTeseoPeer::doSelect($c);
foreach ($teseo_tags as $teseo_tag) {
    $teseo_tag_id = $teseo_tag->getId();
    $teseo_tag_value = trim($teseo_tag->getDenominazione());
    $teseo_tag_tipo_id = $teseo_tag->getTipoTeseoId();
    if ($teseo_tag_tipo_id == 0) {
        continue;
    }
    $teseo_tag_tipo = OppTipoTeseoPeer::retrieveByPK($teseo_tag_tipo_id);
    $teseo_tag_tipo_name = $teseo_tag_tipo->getTipo();
    echo $teseo_tag_id . ": " . $teseo_tag_value . "\n";
    $sfTag = TagPeer::retrieveOrCreateByTagname("{$teseo_tag_tipo_name}:{$teseo_tag_id}={$teseo_tag_value}");
    $sfTag->save();
    foreach ($teseo_tag->getOppTeseoHasTeseotts() as $teseo_tt) {
        $tt_id = $teseo_tt->getOppTeseott()->getId();
        $tt_denominazione = $teseo_tt->getOppTeseott()->getDenominazione();
        echo "  TT" . $tt_id . ": " . $tt_denominazione . "\n";
        $tt = OppTagHasTtPeer::retrieveByPK($sfTag->getId(), $tt_id);
        if (!$tt instanceof OppTagHasTt) {
            $tt = new OppTagHasTt();
        }
        $tt->setTagId($sfTag->getId());
        $tt->setTeseoTtId($tt_id);
        $tt->save();
    }
    foreach ($teseo_tag->getOppAttoHasTeseos() as $atto_tag) {
        if (!$atto_tag->getOppAtto() instanceof OppAtto) {
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:transfer_tags.php


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