>>>database<<<
1. Modify protected/config/main.php
Remove the annotations to the MySQL database connection and modify the username, password, and connected database.
2. New protected/tests/unit/dbtest.php
The contents are as follows:
<?php
class Dbtest extends Ctestcase
{public
function testconnection ()
{
$this-> Assertnotequals (NULL, Yii::app ()->db);
}
3. Implementation
C:\xampp\yii\power\protected\tests> PHPUnit. \unit\dbtest.php
>>>end of datebase<<<
YII MySQL Modify database data
Learn the latest Yii framework, share some learning experience, suitable for beginners, great god please press CTRL + W
The first of these methods
The <?php/
* $id represents a primary key and can be one or a collection.
* $attributes represents the collection of fields to be modified.
* $condition represent conditions.
* $params the value passed in.
* *
$count = Model::model ()->updatebypk ($id, $attributes, $condition, $params);
if ($count > 0) {
echo ' modified successfully ';
} else {
echo ' modification failed ';
}
? >
The second method
<?php
$model = Model::model ()->findbypk ($id);
$model->username = ' yiistudy ';
$model->password = ' mysql ';
$count = $model->update (Array (' username ', ' password '));
if ($count >0) {
echo ' modified successfully ';
} else {
echo ' modification failed ';
}
? >