简体   繁体   中英

Laravel 4 model without eloquent

I'm just starting to learn about Laravel and trying to migrate from CI. I have a few simple questions.

  1. Do I have to use eloquent when using a model?
  2. In CI using model you just extends Model. Is there the same to use in Laravel? So far all the docs I found only state that I have to use eloquent if I want to use model. Eloquent is a bit confusing at the moment for me. So I just want to use simple query builder in my model.

I guess number 1 and 2 questions are somehow related.

You can use fluent:

DB::table("...");

Eloquent, which is based on PDO is ORM and more abstracted from raw queries.

Eloquent is a great tool, so I recommend familiarizing yourself with it if you get the chance.

You can build queries on your own using Laravel's query builder.

Read up on it here, I hope this answers your question and sorry if I misunderstood!

http://laravel.com/docs/queries

Good luck!

I think you can`t create a model without extends eloquent like laravel 4 Doc

class User extends Eloquent {}

because a model in laravel based into eloquent ORM unlike CodeIgniter

If you need to deal with database tables with creating models ,you can use DB class like laravel 4 Doc

DB::select('') and DB::table('')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM