scusate se rispondo oggi ma ero influenzato, ho corretto le rules sul model dove c’è la search, ma il risultato rimane
Model
<?php
/**
* This is the model class for table "attivita".
*
* The followings are the available columns in table 'attivita':
* @property string $id
* @property string $eventi_id
* @property string $nome
* @property string $descrizione
* @property string $indirizzo
* @property string $titolo
* @property string $coordinate
* @property string $image
* @property string $categoria
* @property string $username
* @property string $psw
* @property string $nome_marca
* The followings are the available model relations:
* @property Marche[] $marches
* @property Offerte[] $offertes
* @property Parcheggi[] $parcheggis
*/
class Attivita extends CActiveRecord
{
public $nome_marca;
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'attivita';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('eventi_id', 'required'),
array('eventi_id', 'length', 'max'=>10),
array('nome, titolo, coordinate, categoria, username, psw', 'length', 'max'=>255),
array('descrizione, indirizzo, image','nome_marca','safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, eventi_id, nome, descrizione, indirizzo, titolo, coordinate, image, categoria, username, psw, nome_marca', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'marches' => array(self::MANY_MANY, 'Marche', 'attivita_marche(marche_id, utenti_id)'),
'offertes' => array(self::HAS_MANY, 'Offerte', 'attivita_id'),
'parcheggis' => array(self::HAS_MANY, 'Parcheggi', 'attivita_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'eventi_id' => 'Eventi',
'nome' => 'Nome',
'descrizione' => 'Descrizione',
'indirizzo' => 'Indirizzo',
'titolo' => 'Titolo',
'coordinate' => 'Coordinate',
'image' => 'Image',
'categoria' => 'Categoria',
'username' => 'Username',
'psw' => 'Psw',
'nome_marca' => 'nome_marca',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo ricerca per nome attività e per marca con relazione Many_To_Many
$criteria=new CDbCriteria;
$criteria->compare('nome',$this->nome,true);
if ($this->nome_marca){
$criteria->with= array('marches');
$criteria->toghether= true;
$criteria->compare('marches.nome_marca', $this->nome_marca,true);
}
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Attivita the static model class
*/
public function categoria(){
/* $criteria=new CDbCriteria;
$criteria->compare('categoria','sportiva');
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));*/
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
errore
PHP warning
include(nome_marca.php): failed to open stream: No such file or directory
C:\xampp\htdocs\sites\yii\framework\YiiBase.php(421)
409 {
410 include($classFile);
411 if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
412 throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
413 '{class}'=>$className,
414 '{file}'=>$classFile,
415 )));
416 break;
417 }
418 }
419 }
420 else
421 include($className.'.php');
422 }
423 else // class name with namespace in PHP 5.3
424 {
425 $namespace=str_replace('\\','.',ltrim($className,'\\'));
426 if(($path=self::getPathOfAlias($namespace))!==false)
427 include($path.'.php');
428 else
429 return false;
430 }
431 return class_exists($className,false) || interface_exists($className,false);
432 }
433 return true;
Stack Trace
#0
+ C:\xampp\htdocs\sites\yii\framework\YiiBase.php(421): YiiBase::autoload()
#1
+ C:\xampp\htdocs\sites\yii\framework\YiiBase.php(296): YiiBase::autoload("nome_marca")
#2
+ C:\xampp\htdocs\sites\yii\framework\validators\CValidator.php(186): YiiBase::import("nome_marca", true)
#3
+ C:\xampp\htdocs\sites\yii\framework\base\CModel.php(287): CValidator::createValidator("nome_marca", Attivita, "descrizione, indirizzo, image", array("safe"))
#4
+ C:\xampp\htdocs\sites\yii\framework\base\CModel.php(260): CModel->createValidators()
#5
+ C:\xampp\htdocs\sites\yii\framework\base\CModel.php(547): CModel->getValidators()
#6
+ C:\xampp\htdocs\sites\yii\framework\base\CModel.php(468): CModel->getSafeAttributeNames()
#7
+ C:\xampp\htdocs\sites\yii\framework\base\CComponent.php(152): CModel->setAttributes(array("nome" => "", "nome_marca" => "And"))
#8
+ C:\xampp\htdocs\sites\yii\framework\db\ar\CActiveRecord.php(161): CComponent->__set("attributes", array("nome" => "", "nome_marca" => "And"))
#9
+ C:\xampp\htdocs\sites\Macerata2\protected\controllers\AttivitaController.php(110): CActiveRecord->__set("attributes", array("nome" => "", "nome_marca" => "And"))
#10
+ C:\xampp\htdocs\sites\yii\framework\web\actions\CInlineAction.php(49): AttivitaController->actionIndex()
#11
+ C:\xampp\htdocs\sites\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array("Attivita" => array("nome" => "", "nome_marca" => "And"), "yt0" => "Search"))
#12
+ C:\xampp\htdocs\sites\yii\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction)
#13
+ C:\xampp\htdocs\sites\yii\framework\web\filters\CFilter.php(40): CFilterChain->run()
#14
+ C:\xampp\htdocs\sites\yii\framework\web\CController.php(1145): CFilter->filter(CFilterChain)
#15
+ C:\xampp\htdocs\sites\yii\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(CFilterChain)
#16
+ C:\xampp\htdocs\sites\yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#17
+ C:\xampp\htdocs\sites\yii\framework\web\CController.php(291): CFilterChain->run()
#18
+ C:\xampp\htdocs\sites\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete"))
#19
+ C:\xampp\htdocs\sites\yii\framework\web\CWebApplication.php(282): CController->run("index")
#20
+ C:\xampp\htdocs\sites\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("attivita/index")
#21
+ C:\xampp\htdocs\sites\yii\framework\base\CApplication.php(180): CWebApplication->processRequest()
#22
– C:\xampp\htdocs\sites\Macerata2\index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11
12 require_once($yii);
13 Yii::createWebApplication($config)->run();