Answers.Body: <blockquote>
  <p>So how can I define table's attributes in Craft 3 to complete following code:</p>
  </blockquote>
  <p>You don't.</p>
  <p>By just defining the table name, that gives Yii enough information to reflect on the underlying columns for the table.</p>
  <p>You can add <a href="https://github.com/craftcms/cms/blob/develop/src/records/Entry.php#L17-L26" rel="nofollow noreferrer">property doc blocks</a> to get type-hinting in your IDE for the columns.</p>
  <p>Probably also worth reading: <a href="https://docs.craftcms.com/v3/extend/updating-plugins.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/updating-plugins.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-19T00:49:11.777Z
Answers.Text: :) Thank you @bell
  
  01. Just property doc? does not have any alternative method?
  02. I've not found anything about the  defineAttributes() in 'updating plugin' docs.
                           Not understood, could you please give me a direct code example to define a table's column in Craft3.
Answers.UserDisplayName: johirpro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-20T03:32:45.490Z
Answers.Text: Not even property docs (that's just useful for an IDE). Define the table name, like you're doing and Yii will take care of the rest. You'll be able to access the column names as properties on your table object.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T19:19:25.973Z
Answers.LastActivityDate: 2020-06-18T19:19:25.973Z
Answers.UserDisplayName: Brad Bell
Body: <p>Following code is working on Craft 2:</p>
  <pre><code>class My_TableRecord extends BaseRecord {
    public function getTableName() {
      return 'my_table';
    }
  
    protected function defineAttributes() {
      return [
        'title'         =&gt; AttributeType::String,
        'description'   =&gt; AttributeType::Mixed
      ];
    }
  }
  </code></pre>
  <p>According to this documentation the <a href="https://docs.craftcms.com/api/v3/craft-db-activerecord.html#public-properties" rel="nofollow noreferrer">defineAttributes()</a> is not available in Craft 3. So how can I define table's attributes in Craft3 to complete following code:</p>
  <pre><code>class My_TableRecord extends ActiveRecord
  {   public static function tableName()
      {
          return '{{%my_table}}';
      }
  
    //equivalent function of defineAttributes() of Craft3 will go here
  
  }
  </code></pre>
  
Tags: <craft3><records>
Title: How to define table attribute in the record file
ThreadText: # How to define table attribute in the record file
  
  (Asked by: username_0 on 2020-06-18)
  
  Following code is working on Craft 2:
  
  ```
  class My_TableRecord extends BaseRecord {
    public function getTableName() {
      return 'my_table';
    }
  
    protected function defineAttributes() {
      return [
        'title'         => AttributeType::String,
        'description'   => AttributeType::Mixed
      ];
    }
  }
  
  ```
  
  According to this documentation the [defineAttributes()](https://docs.craftcms.com/api/v3/craft-db-activerecord.html#public-properties) is not available in Craft 3. So how can I define table's attributes in Craft3 to complete following code:
  
  ```
  class My_TableRecord extends ActiveRecord
  {   public static function tableName()
      {
          return '{{%my_table}}';
      }
  
    //equivalent function of defineAttributes() of Craft3 will go here
  
  }
  
  ```
  
  **Tags:** craft3, records
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-18. Score: 1
  
  > So how can I define table's attributes in Craft 3 to complete following code:
  
  You don't.
  
  By just defining the table name, that gives Yii enough information to reflect on the underlying columns for the table.
  
  You can add [property doc blocks](https://github.com/craftcms/cms/blob/develop/src/records/Entry.php#L17-L26) to get type-hinting in your IDE for the columns.
  
  Probably also worth reading: <https://docs.craftcms.com/v3/extend/updating-plugins.html>
  
  > **Comments:**
  > **username_0**: :) Thank you @username_1  01. Just property doc? does not have any alternative method? 02. I've not found anything about the  defineAttributes() in 'updating plugin' docs.                          Not understood, could you please give me a direct code example to define a table's column in Craft3.  
  > **username_1**: Not even property docs (that's just useful for an IDE). Define the table name, like you're doing and Yii will take care of the rest. You'll be able to access the column names as properties on your table object.  
  
  ---
  
  