简体   繁体   English

Laravel 4模型没有雄辩

[英]Laravel 4 model without eloquent

I'm just starting to learn about Laravel and trying to migrate from CI. 我刚刚开始学习Laravel,并尝试从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. 在使用模型的CI中,您只需扩展模型。 Is there the same to use in Laravel? 在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. 雄辩的,基于PDO的是ORM,并且从原始查询中抽象出来。

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. 您可以使用Laravel的查询构建器自行构建查询。

Read up on it here, I hope this answers your question and sorry if I misunderstood! 在这里阅读它,我希望这能回答您的问题,如果我误解了,对不起!

http://laravel.com/docs/queries http://laravel.com/docs/queries

Good luck! 祝好运!

I think you can`t create a model without extends eloquent like laravel 4 Doc 我认为您不能像laravel 4 Doc那样扩展eloquent创建模型

class User extends Eloquent {}

because a model in laravel based into eloquent ORM unlike CodeIgniter 因为 laravel中的模型基于eloquent ORMCodeIgniter不同)

If you need to deal with database tables with creating models ,you can use DB class like laravel 4 Doc 如果您需要通过创建模型来处理数据库表,则可以使用laravel 4 Doc这样的DB类。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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