To insert a test:
A simple controller:
function Actionjia () { $goods _model = new Goods ();//Add different from query cannot use the following method// $goods _model=goods::model (); $goods _model->goods_name = ' Apple phone '; $goods _model->goods_price = ' 5199 '; $goods _model->goods_weight=102; Var_dump ($goods _model->save ()); Var_dump ($goods _model); if ($goods _model->save ()) { echo ' success '; } else{ echo "error"; } }
Display the log information at the bottom of the page:
To set the master profile about the DB option:
Such as:
' DB ' =>array (' connectionString ' = ' mysql:host=localhost;dbname=php0507 ', ' emulateprepare ' = ' = True, ' Username ' + ' root ', ' password ' + ', ' charset ' and ' utf8 ', ' tableprefix ' = ' sw_ ', // ' Enableparamlogging ' =>true,//does not display parameter information for SQL statement bindings),
: The reason is that using PDO is a preprocessing, followed by a parameter
After adding:
。
Why is this set?
main.php the master configuration file loads the DB component, and the DB component is below this path \framework\db
YII Displays SQL for debugging