PHP code example of ynamics / relatedsearchbehavior
1. Go to this page and download the library: Download ynamics/relatedsearchbehavior library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function __call($name,$parameters) {
try {
return parent::__call($name,$parameters);
} catch (CException $e) {
if(preg_match(
'/'.Yii::t(
'yii',
quotemeta(
Yii::t(
'yii',
'{class} and its behaviors do not have a method or closure named "{name}".'
)
),
array('{class}'=>'.*','{name}'=>'.*')
)
.'/',$e->getMessage())) {
return $this->autoScope($name, $parameters);
} else {
throw $e;
}
}
}
/**
* Search method valid for all Active Records (with RelatedSearchBehavior)
*
* @return KeenActiveDataProvider
*/
public function search() {
$criteria=new CDbCriteria();
$t=$this->getTableAlias(false, false);
$ds=$this->getDbConnection()->getSchema();
$columns=$this->getMetaData()->columns;
//$relations=$this->relations;
foreach ($this->getSafeAttributeNames() as $attribute) {
$value=$this->{$attribute};
if ($value==='=') {
$value=array(null,'');
}
if (is_array($value)&&!empty($value)||(!is_array($value)&&"$value" !== "")) {
if (isset($columns[$attribute])) {
if (in_array($attribute,$this->exactSearchAttributes())) {
Yii::trace("Exact match
*/
}
}
// $criteria->together=true;
return $this->relatedSearch($criteria
//,array('sort'=>array('defaultOrder'=>$this->getTableAlias(true,false).'.entity_id DESC'))
);
}
/**
* Provides the list of attributes for which an exact search is
* needed and not a partial search.
* (typical: keys, enums, etc.
* @return string[]
*/
public function exactSearchAttributes() {
return [];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.