0

私はプラドに不慣れで、これを自分のテーブルに移す方法に問題があります。これまでのところ、これは私が行ったことです:

ホームページ:

    <com:TForm>
      <com:TRepeater ID="test">
        <prop:HeaderTemplate>
          <table class="list" border="1px" borderWidth="1px" borderColor="#CCCCCC" style="margin-top: 30px;">
             <tr>
              <th>Name</th>
              <th>Email</th>
             </tr>
        </prop:HeaderTemplate>
        <prop:ItemTemplate>
          <tr>
            <td><%#  xxxxxxxx%></>      <!--this is the part where i will put my... -->
            <td><%# xxxxxxxxxx%></>     <!--...data from database -->
          </tr>
        </prop:ItemTemplate>

      </com:TRepeater>
    </com:TForm>

と私のHome.php:

            <?php

            class Home extends TPage
            {
                protected function getListTest()
                {
                    // Returns an array containing all the records from the table
                    return TestRecord::finder()->findAll();
                }
                public function onLoad($param)
                {
                    if (!$this->IsPostBack)
                    {
                        // Populate the Test Drop Down from database values
                        $this->test->DataKeyField = 'username';
                        $this->test->DataKeyField = 'email';
                        $this->test->DataSource = $this->ListTest;

                        $this->test->dataBind();
                    }
                }           
            }
            ?>

私はすでにデータベースとの接続を確立しています。では、データベースのアイテムをテーブルに入力するにはどうすればよいですか?

4

1 に答える 1

2

getListTest()がレコードの適切な配列を返していると仮定すると(チェックするにはvar_dump it)、リピーターの$this->dataを参照するだけで済みます。スコープはリピーターです。したがって、$thisはリピーターオブジェクトのエイリアスです。リピーターが配列を反復処理すると、$this->dataが現在のレコードに変更されます。

    <prop:ItemTemplate>
      <tr>
        <td><%#  $this->data->username %></>     
        <td><%#  $this->data->email %></>     
      </tr>
    </prop:ItemTemplate>
于 2012-09-18T14:59:07.930 に答える