1

目前我正在将此指南用于 Yii2 教程:http ://www.yiiframework.com/doc-2.0/guide-start-databases.html

我尝试根据我的 Oracle SQL 数据库将 Country 示例修改为我自己的表,但我不断收到此错误。

在此处输入图像描述

这是我的模型(AlumniReportListing.php);

<?php

namespace app\models;

use yii\db\ActiveRecord;

class AlumniReportListing extends ActiveRecord
{

}

这是控制器(AlumniReportListingController);

<?php

namespace app\controllers;

use yii\web\Controller;
use yii\data\Pagination;
use app\models\AlumniReportListing;

class AlumniReportListingController extends Controller
{
public function actionIndex()
{
    $query = ALUMNI_MEMBER_DETAIL::find();

    $pagination = new Pagination([
        'defaultPageSize' => 5,
        'totalCount' => $query->count(),
    ]);

    $student = $query->orderBy('AMD_STUD_ID')
        ->offset($pagination->offset)
        ->limit($pagination->limit)
        ->all();

    return $this->render('index', [
        'student' => $student,
        'pagination' => $pagination,
    ]);
}
}

最后是 View(index.php);

<?php
use yii\helpers\Html;
use yii\widgets\LinkPager;
?>
<h1>Alumni Student Listing</h1>
<ul>
<?php foreach ($student as $stud): ?>
    <li>
        <?= Html::encode("{$stud->AMD_STUD_ID} ({$stud->AMD_MEM_ID})") ?>:
        <?= $stud->AMD_NAME ?>
    </li>
<?php endforeach; ?>
</ul>

<?= LinkPager::widget(['pagination' => $pagination]) ?>

我相信我需要做一些事情来创建 ALUMNI_MEMBER_DETAIL 以使其作为对象存在,但是我对如何做到这一点感到很困惑,因为 Country 示例可以正常工作。

4

0 回答 0