public static function getMakeoverEntries($subp_id, $puser_id, $puser_ids) { $c = new Criteria(); $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP); $c->add(entryPeer::STATUS, entryStatus::READY); $c->addSelectColumn("MAX(" . entryPeer::ID . ")"); $c->addSelectColumn(PuserRolePeer::PUSER_ID); $c->addGroupByColumn(PuserRolePeer::KSHOW_ID); $c->addJoin(entryPeer::KSHOW_ID, PuserRolePeer::KSHOW_ID); $c->add(PuserRolePeer::SUBP_ID, $subp_id); $c->add(PuserRolePeer::ROLE, PuserRole::PUSER_ROLE_RECIPIENT); $c->add(PuserRolePeer::PUSER_ID, explode(",", $puser_ids . ',' . $puser_id), Criteria::IN); $rs = entryPeer::doSelectStmt($c); $entry_ids = array(); $entry_puser_ids = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $entry_ids[] = $record[0]; $entry_puser_ids[] = $record[1]; } // // old code from doSelectRs // while($rs->next()) // { // $entry_ids[] = $rs->getInt(1); // $entry_puser_ids[] = $rs->getString(2); // } return array($entry_ids, $entry_puser_ids); }
public static function getKshowRoughcutCount(array $kuser_id_list) { $c = new Criteria(); $c->add(entryPeer::TYPE, entryType::MIX); $c->add(entryPeer::KSHOW_ID, $kuser_id_list, Criteria::IN); $c->addSelectColumn(entryPeer::KSHOW_ID); $c->addAsColumn('cnt', 'COUNT(' . entryPeer::KSHOW_ID . ')'); $c->addGroupByColumn(entryPeer::KSHOW_ID); $rs = entryPeer::doSelectStmt($c); $kusers_roughcuts = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $id = $record[0]; $cnt = $record[1]; $kusers_roughcuts[$id] = $cnt; } // // old code from doSelectRs // while($rs->next()) // { // $id= $rs->getInt(1); // $cnt = $rs->getInt(2); // $kusers_roughcuts[$id]=$cnt; // } $rs->close(); return $kusers_roughcuts; }
/** * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. * * This will only work if the object has been saved and has a valid primary key set. * * @param boolean $deep (optional) Whether to also de-associated any related objects. * @param PropelPDO $con (optional) The PropelPDO connection to use. * @return void * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db */ public function reload($deep = false, PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); } if ($this->isNew()) { throw new PropelException("Cannot reload an unsaved object."); } if ($con === null) { $con = Propel::getConnection(entryPeer::DATABASE_NAME, Propel::CONNECTION_READ); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. $stmt = entryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); $row = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } $this->hydrate($row, 0, true); // rehydrate if ($deep) { // also de-associate any related objects? $this->akshow = null; $this->akuser = null; $this->aaccessControl = null; $this->aconversionProfile2 = null; $this->collkvotes = null; $this->lastkvoteCriteria = null; $this->collconversions = null; $this->lastconversionCriteria = null; $this->collWidgetLogs = null; $this->lastWidgetLogCriteria = null; $this->collmoderationFlags = null; $this->lastmoderationFlagCriteria = null; $this->collroughcutEntrysRelatedByRoughcutId = null; $this->lastroughcutEntryRelatedByRoughcutIdCriteria = null; $this->collroughcutEntrysRelatedByEntryId = null; $this->lastroughcutEntryRelatedByEntryIdCriteria = null; $this->collwidgets = null; $this->lastwidgetCriteria = null; $this->collassetParamsOutputs = null; $this->lastassetParamsOutputCriteria = null; $this->collassets = null; $this->lastassetCriteria = null; } // if (deep) }
public function getEntriesIds() { if ($this->executed) { return array(); } if (!count($this->entryFilters)) { $c = clone $this->baseCriteria; $c->applyFilters(); $c->clearSelectColumns(); $c->addSelectColumn(entryPeer::ID); $rs = entryPeer::doSelectStmt($c); return $rs->fetchAll(PDO::FETCH_COLUMN); } $entries = array(); foreach ($this->entryFilters as $entryFilter) { $c = clone $this->baseCriteria; $entryFilter->attachToCriteria($c); $c->applyFilters(); $c->clearSelectColumns(); $c->addSelectColumn(entryPeer::ID); $rs = entryPeer::doSelectStmt($c); $moreEntries = $rs->fetchAll(PDO::FETCH_COLUMN); $entries += $moreEntries; } return $entries; }
/** * Selects a collection of entry objects pre-filled with all related objects. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of entry objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } entryPeer::addSelectColumns($criteria); $startcol2 = entryPeer::NUM_COLUMNS - entryPeer::NUM_LAZY_LOAD_COLUMNS; kshowPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (kshowPeer::NUM_COLUMNS - kshowPeer::NUM_LAZY_LOAD_COLUMNS); kuserPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + (kuserPeer::NUM_COLUMNS - kuserPeer::NUM_LAZY_LOAD_COLUMNS); accessControlPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + (accessControlPeer::NUM_COLUMNS - accessControlPeer::NUM_LAZY_LOAD_COLUMNS); conversionProfile2Peer::addSelectColumns($criteria); $startcol6 = $startcol5 + (conversionProfile2Peer::NUM_COLUMNS - conversionProfile2Peer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(entryPeer::KSHOW_ID, kshowPeer::ID, $join_behavior); $criteria->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, $join_behavior); $criteria->addJoin(entryPeer::ACCESS_CONTROL_ID, accessControlPeer::ID, $join_behavior); $criteria->addJoin(entryPeer::CONVERSION_PROFILE_ID, conversionProfile2Peer::ID, $join_behavior); $stmt = entryPeer::doSelectStmt($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = entryPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = entryPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = entryPeer::getOMClass($row, 0); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); entryPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined kshow rows $key2 = kshowPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = kshowPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = kshowPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); kshowPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (entry) to the collection in $obj2 (kshow) $obj2->addentry($obj1); } // if joined row not null // Add objects for joined kuser rows $key3 = kuserPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = kuserPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = kuserPeer::getOMClass(false); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); kuserPeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (entry) to the collection in $obj3 (kuser) $obj3->addentry($obj1); } // if joined row not null // Add objects for joined accessControl rows $key4 = accessControlPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = accessControlPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = accessControlPeer::getOMClass(false); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); accessControlPeer::addInstanceToPool($obj4, $key4); } // if obj4 loaded // Add the $obj1 (entry) to the collection in $obj4 (accessControl) $obj4->addentry($obj1); } // if joined row not null // Add objects for joined conversionProfile2 rows $key5 = conversionProfile2Peer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = conversionProfile2Peer::getInstanceFromPool($key5); if (!$obj5) { $cls = conversionProfile2Peer::getOMClass(false); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); conversionProfile2Peer::addInstanceToPool($obj5, $key5); } // if obj5 loaded // Add the $obj1 (entry) to the collection in $obj5 (conversionProfile2) $obj5->addentry($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
protected static function deleteErrorEntries() { $criteria = new Criteria(); $criteria->add(entryPeer::STATUS, array(entryStatus::READY, entryStatus::DELETED), Criteria::NOT_IN); $criteria->add(entryPeer::UPDATED_AT, self::$errObjectsUpdatedAt, Criteria::LESS_THAN); $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . entryPeer::UPDATED_AT . '))'); $stmt = entryPeer::doSelectStmt($criteria); $mins = $stmt->fetchAll(PDO::FETCH_COLUMN); if (!count($mins)) { return; } $errObjectsUpdatedAtStart = reset($mins); if (is_null($errObjectsUpdatedAtStart)) { return; } $errObjectsUpdatedAtEnd = min(self::$errObjectsUpdatedAt, $errObjectsUpdatedAtStart + 60 * 60 * 24 * 30); // month $criteria = new Criteria(); $criteria->add(entryPeer::STATUS, array(entryStatus::READY, entryStatus::DELETED), Criteria::NOT_IN); $criteria->add(entryPeer::UPDATED_AT, $errObjectsUpdatedAtStart, Criteria::GREATER_EQUAL); $criteria->addAnd(entryPeer::UPDATED_AT, $errObjectsUpdatedAtEnd, Criteria::LESS_THAN); $criteria->addDescendingOrderByColumn(entryPeer::LENGTH_IN_MSECS); $criteria->setLimit(self::$queryLimit); $entries = entryPeer::doSelect($criteria); foreach ($entries as $entry) { /* @var $entry entry */ KalturaLog::info("Deleting entry [" . $entry->getId() . "]"); try { myEntryUtils::deleteEntry($entry); } catch (Exception $e) { KalturaLog::err($e); } } self::incrementSummary('entry', count($entries)); kMemoryManager::clearMemory(); }
date_default_timezone_set(kConf::get('date_default_timezone')); $dbConf = kConf::getDB(); DbManager::setConfig($dbConf); DbManager::initialize(); $entryCriteria = new Criteria(); $entryCriteria->add(entryPeer::STATUS, entry::ENTRY_STATUS_READY); $entryCriteria->add(entryPeer::MEDIA_TYPE, array(entry::ENTRY_MEDIA_TYPE_AUDIO, entry::ENTRY_MEDIA_TYPE_VIDEO), Criteria::IN); $entryCriteria->add(entryPeer::LENGTH_IN_MSECS, array(0, null), Criteria::IN); if (!is_null($partnerId)) { $entryCriteria->add(entryPeer::PARTNER_ID, $partnerId); } $entryCriteria->setLimit(8000); $entryCriteria->clearSelectColumns(); $entryCriteria->addSelectColumn(entryPeer::ID); $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2); $rs = entryPeer::doSelectStmt($entryCriteria, $con); $entries = $rs->fetchAll(PDO::FETCH_COLUMN); $saved = 0; foreach ($entries as $entryId) { entryPeer::clearInstancePool(); flavorAssetPeer::clearInstancePool(); mediaInfoPeer::clearInstancePool(); $flavorAssetCriteria = new Criteria(); $flavorAssetCriteria->add(flavorAssetPeer::STATUS, flavorAsset::FLAVOR_ASSET_STATUS_READY); $flavorAssetCriteria->clearSelectColumns(); $flavorAssetCriteria->addSelectColumn(flavorAssetPeer::ID); $flavorAssetCriteria->add(flavorAssetPeer::ENTRY_ID, $entryId); $rs = flavorAssetPeer::doSelectStmt($flavorAssetCriteria, $con); $flavorAssets = $rs->fetchAll(PDO::FETCH_COLUMN); if (!count($flavorAssets)) { continue;