Answer the question
In order to leave comments, you need to log in
What does yii2 output?
There is a database named u13461 (it has a result table and 3 fields id, date, result)
I create a model file results.php (In the models folder)
I write here
namespace app\models;
use yii\db\ActiveRecord;
class results extends ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
/**
* @return string название таблицы, сопоставленной с этим ActiveRecord-классом.
*/
public static function tableName()
{
return 'result';
}
}
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\EntryForm;
use app\models\results;
class SiteController extends Controller
{
public function actionIndex()
{
$query = results::find()->all();
return $this->render('index', [
'query' => $query
]);
}
}
echo "<pre>";
print_r($query);
echo "</pre>";
Array
(
[0] => app\models\results Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
[1] => app\models\results Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
[2] => app\models\results Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
[3] => app\models\results Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[date] =>
[result] => 0
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question