本文整理汇总了PHP中TagPeer::doSelectRS方法的典型用法代码示例。如果您正苦于以下问题:PHP TagPeer::doSelectRS方法的具体用法?PHP TagPeer::doSelectRS怎么用?PHP TagPeer::doSelectRS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagPeer
的用法示例。
在下文中一共展示了TagPeer::doSelectRS方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSioccupadi
public function executeSioccupadi()
{
$options = array('limit' => 20, 'sort_by_relevance' => true);
// estrazione tag, tipo firma, tipo atto
// questo dovrebbe andare in TagPeer, ma romperebbe la neutralità del plugin
$c = new Criteria();
$c->addJoin(OppCaricaHasAttoPeer::ATTO_ID, OppAttoPeer::ID);
$c->addJoin(TaggingPeer::TAGGABLE_ID, OppAttoPeer::ID);
$c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID);
$c->add(OppCaricaHasAttoPeer::CARICA_ID, $this->carica->getId());
$c->add(TaggingPeer::TAGGABLE_MODEL, 'OppAtto');
$c->clearSelectColumns();
$c->addSelectColumn(TagPeer::TRIPLE_VALUE);
$c->addSelectColumn(OppCaricaHasAttoPeer::TIPO);
$c->addSelectColumn(OppAttoPeer::TIPO_ATTO_ID);
// costruzione array associativo dei tag
$tags = array();
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$value = $rs->getString(1);
$tipo = $rs->getString(2);
$tipo_atto_id = $rs->getInt(3);
if (!array_key_exists($value, $tags)) {
$tags[$value] = 0;
}
$tags[$value] += OppCaricaHasAttoPeer::get_fattore_firma($tipo) * OppAttoPeer::get_fattore_tipo_atto($tipo_atto_id);
}
// ordinamento per rilevanza, prima dello slice
arsort($tags);
// slice dell'array, se specificata l'opzione limit
if (isset($options['limit']) && count($tags) > $options['limit']) {
$this->n_remaining_tags = count($tags) - $options['limit'];
$tags = array_slice($tags, 0, $options['limit'], true);
}
// ordinamento per triple_value, in caso sort_by_relevance non sia specificato
if (!isset($options['sort_by_relevance']) || true !== $options['sort_by_relevance']) {
krsort($tags);
}
$this->tags = $tags;
}
示例2: countTagsUnderTermMonitoredByUser
/**
* conta il numero di tag sotto il term, monitorati da un utente (o da tutti gli utenti)
*
* @param string $term_id
* @param string $user_id - se null, torna il num. di tag monitorati da tutti gli utenti
* @return void
* @author Guglielmo Celata
*/
public static function countTagsUnderTermMonitoredByUser($term_id, $user_id = null)
{
// fetch degli id dei tag sotto il term
$c = new Criteria();
$c->add(OppTagHasTtPeer::TESEOTT_ID, $term_id);
$c->addJoin(OppTagHasTtPeer::TAG_ID, TagPeer::ID);
$c->clearSelectColumns();
$c->addSelectColumn(TagPeer::ID);
$tags = array();
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$tags[] = $rs->getInt(1);
}
// conteggio dei tag
$c = new Criteria();
if (!is_null($user_id)) {
$c->add(MonitoringPeer::USER_ID, $user_id);
}
$c->add(MonitoringPeer::MONITORABLE_MODEL, 'Tag');
$c->add(MonitoringPeer::MONITORABLE_ID, $tags, Criteria::IN);
return MonitoringPeer::doCount($c);
}
示例3: postSave
/**
* Tags saving logic, runned after the object himself has been saved
*
* @param BaseObject $object
*/
public function postSave(BaseObject $object)
{
$tags = self::get_tags($object);
$removed_tags = self::get_removed_tags($object);
// save new tags
foreach ($tags as $tagname) {
$tag = TagPeer::retrieveOrCreateByTagName($tagname);
$tag->save();
$tagging = new Tagging();
$tagging->setTagId($tag->getId());
$tagging->setTaggableId($object->getPrimaryKey());
$tagging->setTaggableModel(get_class($object));
$tagging->save();
}
// remove removed tags
$c = new Criteria();
$c->add(TagPeer::NAME, $removed_tags, Criteria::IN);
$rs = TagPeer::doSelectRS($c);
$removed_tag_ids = array();
while ($rs->next()) {
$removed_tag_ids[] = $rs->getInt(1);
}
$c = new Criteria();
$c->add(TaggingPeer::TAG_ID, $removed_tag_ids, Criteria::IN);
$c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey());
$c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object));
TaggingPeer::doDelete($c);
$tags = array_merge(self::get_tags($object), $this->getSavedTags($object));
self::set_saved_tags($object, $tags);
self::clear_tags($object);
self::clear_removed_tags($object);
}
示例4: doSelect
public static function doSelect(Criteria $criteria, $con = null)
{
return TagPeer::populateObjects(TagPeer::doSelectRS($criteria, $con));
}
示例5: postSave
/**
* Tags saving logic, runned after the object himself has been saved
*
* @param BaseObject $object
*/
public function postSave(BaseObject $object)
{
$tags = self::get_tags($object);
$removed_tags = self::get_removed_tags($object);
// read some config parameters and defaults
$anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
$allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all'));
$tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array()));
$use_unique_triple_values = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_use_unique_triple_values', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_use_unique_triple_values', false));
$user = @sfContext::getInstance()->getUser();
// save new tags
foreach ($tags as $tagname) {
if ($use_unique_triple_values) {
$tag = TagPeer::retrieveOrCreateByTripleValue($tagname);
} else {
$tag = TagPeer::retrieveOrCreateByTagName($tagname);
}
$tag->save();
$tagging = TaggingPeer::retrieveOrCreateByTagAndTaggable($tag->getId(), $object->getPrimaryKey(), get_class($object));
$user_id = deppPropelActAsTaggableToolkit::getUserId();
if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '') {
if ($tagging->isNew()) {
$tagging->setUserId($user_id);
}
}
$tagging->save();
}
// remove removed tags
$removed_tag_ids = array();
$c = new Criteria();
$c->add(TagPeer::NAME, $removed_tags, Criteria::IN);
if (Propel::VERSION >= '1.3') {
$rs = TagPeer::doSelectStmt($c);
while ($row = $rs->fetch(PDO::FETCH_ASSOC)) {
$removed_tag_ids[] = intval($row['ID']);
}
} else {
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$removed_tag_ids[] = $rs->getInt(1);
}
}
$c = new Criteria();
$c->add(TaggingPeer::TAG_ID, $removed_tag_ids, Criteria::IN);
$c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey());
$c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object));
$user_id = deppPropelActAsTaggableToolkit::getUserId();
// for authenticated users that do not have tagging_removal_credentials
// if the only tags they're allowed to remove are their own
// then, remove only those tags
// this only works, if anonymnous_tagging is set to false
if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '' && $allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) {
$c->add(TaggingPeer::USER_ID, $user_id);
}
// delete e non doDelete, in modo che anche sul tagging si possano attivare i behavior (per le news)
// TaggingPeer::doDelete($c);
$tags_to_delete = TaggingPeer::doSelect($c);
foreach ($tags_to_delete as $tag_to_delete) {
$tag_to_delete->delete();
}
$tags = array_merge(self::get_tags($object), $this->getSavedTags($object));
self::set_saved_tags($object, $tags);
self::clear_tags($object);
self::clear_removed_tags($object);
}
示例6: getAllWithCount
/**
* Returns all tags, sorted by name, with their number of occurencies.
* The first optionnal parameter permits to add some restrictions on the
* objects the selected tags are related to.
* The second optionnal parameter permits to restrict the tag selection with
* different criterias
*
* @param Criteria $c
* @param array $options
* @return array
*/
public static function getAllWithCount(Criteria $c = null, $options = array())
{
$tags = array();
if (null === $c) {
$c = new Criteria();
}
if (isset($options['limit'])) {
$c->setLimit($options['limit']);
}
if (isset($options['model'])) {
$c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
}
if (isset($options['like'])) {
$c->add(TagPeer::NAME, $options['like'], Criteria::LIKE);
}
if (isset($options['triple'])) {
$c->add(TagPeer::IS_TRIPLE, $options['triple']);
}
if (isset($options['namespace'])) {
$c->add(TagPeer::TRIPLE_NAMESPACE, $options['namespace']);
}
if (isset($options['key'])) {
$c->add(TagPeer::TRIPLE_KEY, $options['key']);
}
if (isset($options['value'])) {
$c->add(TagPeer::TRIPLE_VALUE, $options['value']);
}
$c->addSelectColumn(TagPeer::NAME);
$c->addSelectColumn('COUNT(' . TagPeer::NAME . ') as counter');
$c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID);
$c->addGroupByColumn(TaggingPeer::TAG_ID);
$c->addDescendingOrderByColumn('counter');
$c->addAscendingOrderByColumn(TagPeer::NAME);
if (Propel::VERSION >= '1.3') {
$rs = TagPeer::doSelectStmt($c);
while ($row = $rs->fetch(PDO::FETCH_NUM)) {
$tags[$row[0]] = $row[1];
}
} else {
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$tags[$rs->getString(1)] = $rs->getInt(2);
}
}
if (!isset($options['sort_by_popularity']) || true !== $options['sort_by_popularity']) {
ksort($tags);
}
return $tags;
}
示例7: getAllWithCount
/**
* Returns all tags, sorted by name, with their number of occurencies.
* The first optionnal parameter permits to add some restrictions on the
* objects the selected tags are related to.
* The second optionnal parameter permits to restrict the tag selection with
* different criterias
*
* @param Criteria $c
* @param array $options
* @return array
*/
public static function getAllWithCount(Criteria $c = null, $options = array())
{
$tags = array();
if ($c == null) {
$c = new Criteria();
}
if (isset($options['limit'])) {
$c->setLimit($options['limit']);
}
if (isset($options['model'])) {
$c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
}
if (isset($options['like'])) {
$c->add(TagPeer::NAME, $options['like'], Criteria::LIKE);
}
if (isset($options['triple'])) {
$c->add(TagPeer::IS_TRIPLE, $options['triple']);
}
if (isset($options['namespace'])) {
$c->add(TagPeer::TRIPLE_NAMESPACE, $options['namespace']);
}
if (isset($options['key'])) {
$c->add(TagPeer::TRIPLE_KEY, $options['key']);
}
if (isset($options['value'])) {
$c->add(TagPeer::TRIPLE_VALUE, $options['value']);
}
$c->addSelectColumn(TagPeer::NAME);
$c->addSelectColumn(TaggingPeer::COUNT);
$c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID);
$c->addGroupByColumn(TaggingPeer::TAG_ID);
$c->addDescendingOrderByColumn(TaggingPeer::COUNT);
$c->addAscendingOrderByColumn(TagPeer::NAME);
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$tags[$rs->getString(1)] = $rs->getInt(2);
}
ksort($tags);
return $tags;
}
示例8: getAllWithCount
/**
* Returns all tags, sorted by name, with their number of occurencies.
* The first optionnal parameter permits to add some restrictions on the
* objects the selected tags are related to.
* The second optionnal parameter permits to restrict the tag selection with
* different criterias
*
* @param Criteria $c
* @param array $options
* @return array
*/
public static function getAllWithCount(Criteria $c = null, $options = array())
{
$tags = array();
if (null === $c) {
$c = new Criteria();
}
if (isset($options['limit'])) {
$c->setLimit($options['limit']);
}
if (isset($options['model'])) {
$c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
}
if (isset($options['like'])) {
$c->add(TagPeer::NAME, $options['like'], Criteria::LIKE);
}
if (isset($options['triple'])) {
$c->add(TagPeer::IS_TRIPLE, $options['triple']);
}
if (isset($options['namespace'])) {
$c->add(TagPeer::TRIPLE_NAMESPACE, $options['namespace']);
}
if (isset($options['key'])) {
$c->add(TagPeer::TRIPLE_KEY, $options['key']);
}
if (isset($options['value'])) {
$c->add(TagPeer::TRIPLE_VALUE, $options['value']);
}
$c->addSelectColumn(TagPeer::NAME);
$c->addSelectColumn('COUNT(' . TagPeer::NAME . ') as counter');
$c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID, Criteria::RIGHT_JOIN);
$c->addGroupByColumn(TaggingPeer::TAG_ID);
if (isset($options['sort_by_popularity'])) {
$c->addDescendingOrderByColumn('counter');
} else {
$c->addAscendingOrderByColumn(TagPeer::TRIPLE_VALUE);
}
if (Propel::VERSION >= '1.3') {
$rs = TagPeer::doSelectStmt($c);
while ($row = $rs->fetch(PDO::FETCH_NUM)) {
$tags[$row[0]] = $row[1];
}
} else {
$rs = TagPeer::doSelectRS($c);
while ($rs->next()) {
$tags[$rs->getString(1)] = $rs->getInt(2);
}
}
/*
* questo ordinava per la chiave (NAME) e quindi in modo errato
* ora il comportamento di default è di ordinare per NAME
* mentre se si vuole l'ordinamento per popolarità va specificato nelle options
* come prima
if (!isset($options['sort_by_popularity']) || (true !== $options['sort_by_popularity']))
{
ksort($tags);
}
*/
return $tags;
}