Yii Framework Churn data type

Source: Internet
Author: User
Yii Framework Change data type
The previous database has a field that is numeric, and I use the Yii tool GII to generate it, model,conttroler,view, and other layers. Later, because of the requirements, to change the value to a string, so I will change the value of the database type (char type). Then put the model layer of the Rules () method under the array: Array (' Aa,bb, ', ' numerical '),

Switch

Array (' AA,BB ', ' length ', ' Max ' =>20),

When I finally entered the character extraction data, the following error occurred:

CDBException
The column name must be a string or an array

D:\web_root\rd1039b\framework\db\schema\CDbCommandBuilder.php (701)

689}
690 if (count ($values) ===1)
691 {
692 $entries =array ();
693 foreach ($values [0] as $name = $value)
694 $entries []= $prefix. $table->columns[$name]->rawname. ($value ===null? ' Is NULL ': ' = '. $value);
695 return implode (' and ', $entries);
696}
697
698 return $this->createcompositeincondition ($table, $values, $prefix);
699}
-Else
701 throw New CDBException (Yii::t (' Yii ', ' Column name must is either a string or an array. '));
702}
......
.......
......
.....
......
Cactiverecord->save ()
249}
250
251
252 if (Yii::app ()->user->role==study_user_role_pi) {
253 $model->entry2who= Yii::app ()->user->username;
254 if ($model, Save ())
255 {
if ($SORT!=3) {
257 $this->todo ($Name, $MH 1, $keyid);
258}
259 Else
.........
..........
........
.......
.
Excuse me master, what is this reason? Please help, thank you Ah!!

------Solution--------------------
690 if (count ($values) ===1) Here $values is the array (' AA,BB ', ' length ', ' Max ' =>20), right? If yes, then count ($values) ===1 is False
------Solution--------------------
Unable to verify the specific error.

You can remove the rules (). Try it, could you. If you can use it, the instructions are a problem with your rules () method. If it doesn't work, it means it's wrong to write somewhere else.

Simple example of rules rule
Public Function Rules ()
{
Return Array (
Array (' name,email ', ' length ', ' Max ' =>6),
);
}

This is a list of specific rules
http://blog.csdn.net/mengxiangbaidu/article/details/7002850
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.