search

Home  >  Q&A  >  body text

laravel eloquent implementation principle

laravel eloquent implementation principle

滿天的星座滿天的星座2753 days ago740

reply all(4)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 16:58:22

    For example:
    <?php

    class BusinessWork extends Eloquent
    {

    /**
     * The database table used by the model.
     * @var string
     */
    protected $table = 'businessWork';
    protected $connection = 'mysql';
    public $timestamps = 0;
    protected $fillable = array(
        'businessId',
        'title',
        'content',
        'createAt',
    );
    

    }

    BusinessWork::find(1); This is how table binding is implemented

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 16:58:22

    Let me try to answer. I'm not familiar with it, I'm new to it, I hope I'm not misleading.
    You can see that BusinessWork inherits Eloquent and has its own tables, operable field properties, etc.
    BusinessWork::find(1) is inherited from Eloquent. It also has some common operations such as fetching all records: BusinessWork::all(), which can also be rewritten in BusinessWork.
    You can take the time to go out and turn left to Baidu or right to Google to download Laravel's Eloquent ORM documentation.
    hope this helps.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 16:58:22

    Use the class reflection mechanism to obtain the class name, and then parse it into a table name.
    Any questions?

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 16:58:22

    For delayed binding implementation, refer to PHP 5.3’s static

    reply
    0
  • Cancelreply