您好, 我使用的环境是xampp
我创建了一个项目,
main.php的内容如下
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'QuotedPrice Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.forms.*',
'application.models.*',
'application.components.*',
),
// application components
'components'=>array(
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, info, debug, trace',
),
),
),
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to set up database
'db'=>array(
'class' => 'system.db.CDbConnection',
'connectionString'=>'mysql:host=172.16.1.138;dbname=quotedprice',
'username'=>'ouyang',
'password'=>'123',
'charset' => 'utf8',
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);
我在models目录里面创建了一个CustomFeed
定义如下
class CustomFeed extends CActiveReocrd{
//消息ID
var $id;
//创建者ID
var $memberId;
//称谓
var $appellation;
//联系方式
var $contact;
//内容
var $context;
//创建日期
var $createTime;
//最后更新日期
var $updateTime;
/**
* Returns the static model of the specified AR class.
* @return CActiveRecord the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/*
* 配置CustomFeed模型的映射关系
*
* @return CustomFeed模型映射关系
*/
public function relations(){
return array(
'author' => array(self::BELONGS_TO, 'Custom', 'memberId'),
);
}
/**
* 模型持久化前效验的前置过滤器, 这里检查是否为新记录, 记录下创建日期和最后修改日期, 此方法为模型入库时自动调用
*/
protected function beforeValidate($on)
{
if($this->isNewRecord)
$this->createTime=$this->updateTime=time();
else
$this->updateTime=time();
return true;
}
}
action如下
class SiteController extends CController
{
//指定布局页面
var $layout = 'site';
/**
* 定义一些基本的action集合, 这里添加了验证码的action
*
*/
public function actions()
{
return array(
// captcha action renders the CAPTCHA image
// this is used by the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xEBF4FB,
),
);
}
/**
* 客户留言页面
*
*/
public function actionCustomMessage(){
$this->render('customMessage');
}
/**
* 保存客户留言信息
*
*/
public function actionSaveCustomFeed(){
Yii::log('已经到达', 'info');
if(isset($_POST['CustomFeed'])){
Yii::log('准备插入数据', 'info');
$customFeed = new CustomFeed($_POST['CustomFeed']);
$customFeed->save();
}
$this->render('fileDownload');
}
}
在linux系统下运行正常,但是在xp和vista系统下都无法运行。
我输入信息,点击保存后,报错见下面附件图片:
请教,谢谢~~!