Jump to content

\IPS\Content\Search\Query how to edit where clause?


BomAle

Recommended Posts

I am finding into a way to access on where property (without extend class) but i have not found any way.

$query = \IPS\Content\Search\Query::init()->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_UPDATED );
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter', FALSE ) as $object )
{
	foreach ( $object->classes as $class )
	{
		if ( in_array('IPS\Content\Polls',class_implements($class)) )
		{
			$filters[] = \IPS\Content\Search\ContentFilter::init( $class, TRUE, FALSE, FALSE );
		}
	}
}
$results = $query->filterByContent($filters)->search();
var_dump($results);exit;

I would:

$this->where[] = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['poll'] . '>=' . intval( 1 );

 

Link to comment
Share on other sites

$select = 'core_polls.*';
$join = array();
foreach ( \IPS\Content::routedClasses( FALSE, FALSE, TRUE ) as $class )
{
	/*FIX, @TODO when __callStatic on IPS\cms\Records1 call the __construct or fix the hook97 "records.php"*/
	if(mb_strpos($class,'IPS\cms\Records') !== FALSE and is_numeric( mb_substr( $class, 15, 1 ) ))
	{
		if(!in_array('\\IPS\cms\\Records', get_declared_classes()))
		{
			new $class;
		}
	}
	if ( in_array('IPS\Content\Polls',class_implements($class)) AND isset($class::$databaseColumnMap['poll']))
	{
		$join[] = array($class::$databaseTable, $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['poll'] . '=core_polls.pid');
		$select .= ', CONCAT("'.\IPS\Db::i()->escape_string($class).'") as item_class, '.$class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId.' as item_id';
	}
}
$query = \IPS\Db::i()->select( $select, 'core_polls' );
foreach($join as $j)
{
	$query->join($j[0],$j[1]);
}
$results = array();
foreach ($query as $k => $r)
{
	if($r['item_class'] AND $r['item_id']){
		$r['item'] = $r['item_class']::load($r['item_id']);
	};
	unset($r['item_class'],$r['item_id']);
	$results[] = $r;
}
var_dump($results);exit;

solved

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...