本文整理汇总了PHP中SelectQuery::addWhereLike方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::addWhereLike方法的具体用法?PHP SelectQuery::addWhereLike怎么用?PHP SelectQuery::addWhereLike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::addWhereLike方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMatching
/**
* Since the agent manager package already has support for filtering agents and
* groups from traversal info iterators, return our search results as traversal
* info.
*
* @param string $criteria
* @return TraversalInfoIterator
* @access protected
* @since 1/31/08
*/
protected function getMatching($criteria)
{
$dbc = Services::getService('DatabaseManager');
$idMgr = Services::getService('Id');
$query = new SelectQuery();
$query->addTable('agent_properties');
$query->addColumn("DISTINCT fk_object_id", "agent_id");
$query->addWhereLike("property_value", str_replace('*', '%', $criteria));
$info = array();
$result = $dbc->query($query, $this->databaseIndex);
while ($result->hasNext()) {
$row = $result->next();
if (!strlen($row['agent_id'])) {
throw new OperationFailedException("No valid agent_id found in row for query: " . $query->asString());
}
$info[] = new HarmoniTraversalInfo($idMgr->getId($row['agent_id']), '', 0);
}
return new HarmoniTraversalInfoIterator($info);
}
示例2: getAssetsBySearch
/**
* Perform a search of the specified Type and get all the Assets that
* satisfy the SearchCriteria. Iterators return a set, one at a time.
*
* @param object mixed $searchCriteria (original type: java.io.Serializable)
* @param object Type $searchType
* @param object Properties $searchProperties
*
* @return object AssetIterator
*
* @throws object RepositoryException An exception with one of
* the following messages defined in
* org.osid.repository.RepositoryException may be thrown: {@link
* org.osid.repository.RepositoryException#OPERATION_FAILED
* OPERATION_FAILED}, {@link
* org.osid.repository.RepositoryException#PERMISSION_DENIED
* PERMISSION_DENIED}, {@link
* org.osid.repository.RepositoryException#CONFIGURATION_ERROR
* CONFIGURATION_ERROR}, {@link
* org.osid.repository.RepositoryException#UNIMPLEMENTED
* UNIMPLEMENTED}, {@link
* org.osid.repository.RepositoryException#NULL_ARGUMENT
* NULL_ARGUMENT}, {@link
* org.osid.repository.RepositoryException#UNKNOWN_TYPE
* UNKNOWN_TYPE}
*
* @access public
*/
function getAssetsBySearch($searchCriteria, Type $searchType, Properties $searchProperties)
{
if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "Keyword", "Search with a string for keywords."))) {
if (!is_string($searchCriteria)) {
throw new OperationFailedException('search criteria should be a string.');
}
// Convert the criteria to the proper character set.
$encoding = $this->config['encoding'];
if (!is_null($encoding)) {
$searchCriteria = iconv('UTF-8', $encoding, $searchCriteria);
}
$query = new SelectQuery();
$query->addTable($this->config['table']);
$query->addColumn($this->config['id_column']);
$query->addWhereLike($this->config['id_column'], '%' . $searchCriteria . '%');
foreach ($this->config['columns'] as $column) {
$query->addColumn($column);
$query->addWhereLike($column, '%' . $searchCriteria . '%', _OR);
}
if ($this->config['order_column']) {
$query->addOrderBy($this->config['order_column'], $this->config['order_direction']);
}
return new SimpleTableAssetIterator($this, $this->config, $this->dbc->query($query, $this->dbIndex));
} else {
if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "RootAssets", "Search for just the 'root' or 'top level' assets which are not assets of other assets."))) {
return $this->getAssets();
} else {
throw new UnknownTypeException('UNKNOWN_TYPE');
}
}
}
示例3: getSlotsWithSitesBySearch
/**
* Answer an array of slots that have sites and whose shortnames match a search string.
* Use '*' as the wildcard.
*
* @param string $searchCriteria
* @return array
* @access public
* @since 10/9/08
*/
public function getSlotsWithSitesBySearch($searchCriteria)
{
if (!strlen($searchCriteria)) {
return array();
}
$searchCriteria = str_replace('*', '%', $searchCriteria);
$query = new SelectQuery();
$query->addTable('segue_slot');
$query->addTable('segue_slot_owner AS all_owners', LEFT_JOIN, 'segue_slot.shortname = all_owners.shortname');
$query->addColumn('segue_slot.shortname', 'shortname');
$query->addColumn('segue_slot.site_id', 'site_id');
$query->addColumn('segue_slot.alias_target', 'alias_target');
$query->addColumn('segue_slot.type', 'type');
$query->addColumn('segue_slot.location_category', 'location_category');
$query->addColumn('segue_slot.media_quota', 'media_quota');
$query->addColumn('all_owners.owner_id', 'owner_id');
$query->addColumn('all_owners.removed', 'removed');
$query->addWhereLike('segue_slot.shortname', $searchCriteria);
$query->addWhereNotEqual('segue_slot.site_id', '');
// printpre($query->asString());
$dbc = Services::getService('DBHandler');
$result = $dbc->query($query, IMPORTER_CONNECTION);
return $this->getSlotsFromQueryResult($result);
}