private function gc() { LanguageObjectPeer::clearInstancePool(); DocumentPeer::clearInstancePool(); SearchIndexPeer::clearInstancePool(); SearchIndexWordPeer::clearInstancePool(); gc_collect_cycles(); }
public static function doValidate(SearchIndex $obj, $cols = null) { $columns = array(); if ($cols) { $dbMap = Propel::getDatabaseMap(SearchIndexPeer::DATABASE_NAME); $tableMap = $dbMap->getTable(SearchIndexPeer::TABLE_NAME); if (!is_array($cols)) { $cols = array($cols); } foreach ($cols as $colName) { if ($tableMap->containsColumn($colName)) { $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); $columns[$colName] = $obj->{$get}(); } } } else { } $res = BasePeer::doValidate(SearchIndexPeer::DATABASE_NAME, SearchIndexPeer::TABLE_NAME, $columns); if ($res !== true) { $request = sfContext::getInstance()->getRequest(); foreach ($res as $failed) { $col = SearchIndexPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); $request->setError($col, $failed->getMessage()); } } return $res; }
public function mayOperate($sOperation, $oUser = false) { $oUser = SearchIndexPeer::getRightsUser($oUser); $bIsAllowed = false; if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && SearchIndexPeer::mayOperateOnOwn($oUser, $this, $sOperation)) { $bIsAllowed = true; } else { if (SearchIndexPeer::mayOperateOn($oUser, $this, $sOperation)) { $bIsAllowed = true; } } FilterModule::getFilters()->handleSearchIndexOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed)); return $bIsAllowed; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = SearchIndexPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setQuestionId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setWord($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setWeight($arr[$keys[2]]); } }
/** * Retrieve object using using composite pkey values. * @param int $id * @param string $language_id * @param PropelPDO $con * @return SearchIndex */ public static function retrieveByPK($id, $language_id, PropelPDO $con = null) { $_instancePoolKey = serialize(array((string) $id, (string) $language_id)); if (null !== ($obj = SearchIndexPeer::getInstanceFromPool($_instancePoolKey))) { return $obj; } if ($con === null) { $con = Propel::getConnection(SearchIndexPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(SearchIndexPeer::DATABASE_NAME); $criteria->add(SearchIndexPeer::ID, $id); $criteria->add(SearchIndexPeer::LANGUAGE_ID, $language_id); $v = SearchIndexPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return SearchIndex A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `id`, `page_id`, `path`, `language_id`, `link_text`, `page_title`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `search_index` WHERE `id` = :p0 AND `language_id` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new SearchIndex(); $obj->hydrate($row); SearchIndexPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); return $obj; }
public function updateSearchIndex() { // update search index $c = new Criteria(); $c->add(SearchIndexPeer::QUESTION_ID, $this->getId()); SearchIndexPeer::doDelete($c); foreach ($this->getWords() as $word => $weight) { $index = new SearchIndex(); $index->setQuestionId($this->getId()); $index->setWord($word); $index->setWeight($weight); $index->save(); } }
<?php define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'frontend'); define('SF_ENVIRONMENT', 'dev'); 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(); SearchIndexPeer::doDeleteAll(); $data = new sfPropelData(); $data->loadData(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'fixtures');
public function countSearchIndexs($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseSearchIndexPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(SearchIndexPeer::QUESTION_ID, $this->getId()); return SearchIndexPeer::doCount($criteria, $distinct, $con); }
/** * Selects a collection of SearchIndexWord objects pre-filled with all related objects except UserRelatedByUpdatedBy. * * @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 SearchIndexWord objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(SearchIndexWordPeer::DATABASE_NAME); } SearchIndexWordPeer::addSelectColumns($criteria); $startcol2 = SearchIndexWordPeer::NUM_HYDRATE_COLUMNS; SearchIndexPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + SearchIndexPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(SearchIndexWordPeer::SEARCH_INDEX_ID, SearchIndexPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SearchIndexWordPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SearchIndexWordPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = SearchIndexWordPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); SearchIndexWordPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined SearchIndex rows $key2 = SearchIndexPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = SearchIndexPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = SearchIndexPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); SearchIndexPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (SearchIndexWord) to the collection in $obj2 (SearchIndex) $obj2->addSearchIndexWord($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }