2016-12-16 68 views
0

我有這個錯誤,我是新的yii框架。在移動到新服務器後,它在另一臺服務器上正常工作,我剛剛替換了我的數據庫和框架;我沒有改變任何東西!這是我的錯誤:Yii框架CDBCommand錯誤

CDbException 

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field 'geolocationDetails' doesn't have a default value. The SQL statement executed was: INSERT INTO `hts_users` (`mobile_status`, `name`, `username`, `email`, `password`, `userstatus`, `activationStatus`, `createdDate`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7) 

/var/www/domain/public_html/folder/framework/db/CDbCommand.php(358) 

346   { 
347    if($this->_connection->enableProfiling) 
348     Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute'); 
349 
350    $errorInfo=$e instanceof PDOException ? $e->errorInfo : null; 
351    $message=$e->getMessage(); 
352    Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.', 
353     array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand'); 
354 
355    if(YII_DEBUG) 
356     $message.='. The SQL statement executed was: '.$this->getText().$par; 
357 
358    throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}', 
359     array('{error}'=>$message)),(int)$e->getCode(),$errorInfo); 
360   } 
361  } 
362 
363  /** 
364  * Executes the SQL statement and returns query result. 
365  * This method is for executing an SQL query that returns result set. 
366  * @param array $params input parameters (name=>value) for the SQL execution. This is an alternative 
367  * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing 
368  * them in this way can improve the performance. Note that if you pass parameters in this way, 
369  * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa. 
370  * Please also note that all values are treated as strings in this case, if you need them to be handled as 
Stack Trace 
#0 
– /var/www/domain/public_html/folder/framework/db/ar/CActiveRecord.php(1080): CDbCommand->execute() 
1075   { 
1076    Yii::trace(get_class($this).'.insert()','system.db.ar.CActiveRecord'); 
1077    $builder=$this->getCommandBuilder(); 
1078    $table=$this->getTableSchema(); 
1079    $command=$builder->createInsertCommand($table,$this->getAttributes($attributes)); 
1080    if($command->execute()) 
1081    { 
1082     $primaryKey=$table->primaryKey; 
1083     if($table->sequenceName!==null) 
1084     { 
1085      if(is_string($primaryKey) && $this->$primaryKey===null) 
#1 
– /var/www/domain/public_html/folder/framework/db/ar/CActiveRecord.php(809): CActiveRecord->insert(null) 
804  * @return boolean whether the saving succeeds 
805  */ 
806  public function save($runValidation=true,$attributes=null) 
807  { 
808   if(!$runValidation || $this->validate($attributes)) 
809    return $this->getIsNewRecord() ? $this->insert($attributes) : $this->update($attributes); 
810   else 
811    return false; 
812  } 
813 
814  /** 
#2 
– /var/www/domain/public_html/folder/protected/modules/admin/controllers/UserController.php(67): CActiveRecord->save(false) 
62    $password = $_POST['Users']['password']; 
63    $model->userstatus = 1; 
64    $model->activationStatus = 1; 
65    if($model->validate()) { 
66     $model->password = base64_encode($password); 
67     $model->save(false); 
68     $siteSettings = Sitesettings::model()->find(); 
69     $mail = new YiiMailer(); 
70     if($siteSettings->smtpEnable == 1) { 
71      //$mail->IsSMTP();       // Set mailer to use SMTP 
72      $mail->Mailer = 'smtp';       // Set mailer to use SMTP 
#3 
– /var/www/domain/public_html/folder/framework/web/actions/CInlineAction.php(49): UserController->actionCreate() 
44   $controller=$this->getController(); 
45   $method=new ReflectionMethod($controller, $methodName); 
46   if($method->getNumberOfParameters()>0) 
47    return $this->runWithParamsInternal($controller, $method, $params); 
48 
49   $controller->$methodName(); 
50   return true; 
51  } 
52 } 
#4 
– /var/www/domain/public_html/folder/framework/web/CController.php(308): CInlineAction->runWithParams(array()) 
303  { 
304   $priorAction=$this->_action; 
305   $this->_action=$action; 
306   if($this->beforeAction($action)) 
307   { 
308    if($action->runWithParams($this->getActionParams())===false) 
309     $this->invalidActionParams($action); 
310    else 
311     $this->afterAction($action); 
312   } 
313   $this->_action=$priorAction; 
#5 
– /var/www/domain/public_html/folder/framework/web/filters/CFilterChain.php(133): CController->runAction(CInlineAction) 
128    $filter=$this->itemAt($this->filterIndex++); 
129    Yii::trace('Running filter '.($filter instanceof CInlineFilter ? get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.filter()'),'system.web.filters.CFilterChain'); 
130    $filter->filter($this); 
131   } 
132   else 
133    $this->controller->runAction($this->action); 
134  } 
135 } 
#6 
– /var/www/domain/public_html/folder/framework/web/CController.php(291): CFilterChain->run() 
286    $this->runAction($action); 
287   else 
288   { 
289    $priorAction=$this->_action; 
290    $this->_action=$action; 
291    CFilterChain::create($this,$action,$filters)->run(); 
292    $this->_action=$priorAction; 
293   } 
294  } 
295 
296  /** 
#7 
– /var/www/domain/public_html/folder/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array("postOnly + delete")) 
260   { 
261    if(($parent=$this->getModule())===null) 
262     $parent=Yii::app(); 
263    if($parent->beforeControllerAction($this,$action)) 
264    { 
265     $this->runActionWithFilters($action,$this->filters()); 
266     $parent->afterControllerAction($this,$action); 
267    } 
268   } 
269   else 
270    $this->missingAction($actionID); 
#8 
– /var/www/domain/public_html/folder/framework/web/CWebApplication.php(282): CController->run("create") 
277   { 
278    list($controller,$actionID)=$ca; 
279    $oldController=$this->_controller; 
280    $this->_controller=$controller; 
281    $controller->init(); 
282    $controller->run($actionID); 
283    $this->_controller=$oldController; 
284   } 
285   else 
286    throw new CHttpException(404,Yii::t('yii','Unable to resolve the request "{route}".', 
287     array('{route}'=>$route===''?$this->defaultController:$route))); 
#9 
– /var/www/domain/public_html/folder/framework/web/CWebApplication.php(141): CWebApplication->runController("admin/user/create") 
136    foreach(array_splice($this->catchAllRequest,1) as $name=>$value) 
137     $_GET[$name]=$value; 
138   } 
139   else 
140    $route=$this->getUrlManager()->parseUrl($this->getRequest()); 
141   $this->runController($route); 
142  } 
143 
144  /** 
145  * Registers the core application components. 
146  * This method overrides the parent implementation by registering additional core components. 
#10 
– /var/www/domain/public_html/folder/framework/base/CApplication.php(184): CWebApplication->processRequest() 
179  public function run() 
180  { 
181   if($this->hasEventHandler('onBeginRequest')) 
182    $this->onBeginRequest(new CEvent($this)); 
183   register_shutdown_function(array($this,'end'),0,false); 
184   $this->processRequest(); 
185   if($this->hasEventHandler('onEndRequest')) 
186    $this->onEndRequest(new CEvent($this)); 
187  } 
188 
189  /** 
#11 
– /var/www/domain/public_html/folder/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(); 
2016-12-16 16:27:08 Apache Yii Framework/1.1.16-dev 

這是整個的錯誤,我得到如果我提前錯過的東西,或者你要我過去的事情讓我知道,謝謝。

+0

你想插入一個空列值的行,不承認空 – scaisEdge

+0

@scaisEdge它移動到一個新的服務器後,它在另一臺服務器上正常工作,我剛剛更換了我的數據庫和我的框架我沒有改變任何東西! –

+1

*我沒有改變任何東西...... * - 服務器和數據庫除外? – gravity

回答

1

問題解決是mysql的配置我加入這個 的sql_mode = IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 謝謝大家誰幫助使用計算器上大加讚賞 多虧了@Gravity