雄辩模型与模型的区别?(The difference between an Eloquent Model and a Model?)
所以,我对此感到困惑:在Laravel的官方文档中,他们说:
Laravel附带的Eloquent ORM为您的数据库提供了一个美丽的,简单的ActiveRecord实现。 每个数据库表都有一个对应的“模型”,用于与该表进行交互。
Ok util这里都很棒,我明白了!
所以我做了一个迁移来创建一个数据库: php artisan make:migration create_items_table --create =“items”
太好了,直到这里:)
所以从理论上讲,当我将make: php artisan make:model Item时 ,Laravel将创建一个php类(用于与items表进行交互):
class Item extends Eloquent { ... }
但是,在现实世界中,当我做: php artisan make:model Item ,Laravel创建php类(用于与items表交互)::
class Item extends Model { ... }
那么为什么模型而不是雄辩? 我错过了什么? 雄辩模型和模型有什么区别。
如果有差异,我应该何时使用雄辩和模型...?
谢谢^^
So, i'm confused with this : In Laravel's official documentation, they say :
The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table.
Ok util here all is Great, i get it !
So I make a migration to create a database : php artisan make:migration create_items_table --create="items"
Great until here too :)
So theoretically speaking, when i will make : php artisan make:model Item , Laravel will create a php class ( which is used to interact with items table) :
class Item extends Eloquent { ... }
But,in real world, when i make : php artisan make:model Item , Laravel creates php class ( which is used to interact with items table) ::
class Item extends Model { ... }
So Why Model and not Eloquent ?? Am i missing sth ? And What's the difference between Eloquent Model and Model.
And if there's a difference, when should i use Eloquent and when Model ... ?
Thank you ^^
原文:https://stackoverflow.com/questions/31380624
最满意答案
这是一个文档限制,Silverlight版本5不支持您尝试使用的构造函数。来自MSDN文章 :
受以下支持:4,3
不是水晶,为什么它被丢弃,可能与它有关[SecurityCritical]。
为什么你的IntelliSense仍然显示它很难猜测,我当然不能重复。 您可能应该验证mscorlib引用的路径,我的指向C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework \ Silverlight \ v5.0 \ mscorlib.dll
It is a documented restriction, the constructor you are trying to use is not supported in Silverlight version 5. From the MSDN article:
Supported in: 4, 3
Not crystal why it was dropped, probably has something to do with it being [SecurityCritical].
Why your IntelliSense still shows it is hard to guess, I certainly can't repro that. You probably ought to verify the path to the mscorlib reference, mine points to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\mscorlib.dll
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
这是一个文档限制,Silverlight版本5不支持您尝试使用的构造函数。来自MSDN文章 : 受以下支持:4,3 不是水晶,为什么它被丢弃,可能与它有关[SecurityCritical]。 为什么你的IntelliSense仍然显示它很难猜测,我当然不能重复。 您可能应该验证mscorlib引用的路径,我的指向C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework \ Silverlight \ v5.0 \ mscorl ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
注入的类名Base是Base类的成员,并且由于基类是依赖的,因此在非限定名称查找期间不会搜索其范围。 因此,使用名称Base只能找到类模板,而不是Base
的注入类名。 这就是你必须写Base 。 Derived::Base有效,因为它会导致名称查找被推迟,直到Derived被实例化。 The injected class name Base is a member of the class Base, and since the base class is dependent, its scop ... -
为什么递归构造函数调用会使无效的C#代码编译?(Why does a recursive constructor call make invalid C# code compile?)[2022-12-12]
有趣的发现。 似乎实际上只有两种实例构造函数: 一个实例构造函数,它使用: this( ...)语法链接相同类型的另一个实例构造函数。 链接基类的实例构造函数的实例构造函数。 这包括没有指定chainig的实例构造函数,因为: base()是默认值。 (我忽略了System.Object的实例构造函数,这是一个特殊情况, System.Object没有基类,但是System.Object也没有字段) 可能存在于类中的实例字段初始化器需要复制到上述类型2的所有实例构造函数的正文的开头,而没有类型1的实例构造函 ... -
合成的构造函数是声明和定义的。 你可能不会自己定义它。 您必须声明自己的构造函数才能提供实现。 [special] (2003年措辞,12/1)说: 默认构造函数(12.1),复制构造函数和复制赋值运算符(12.8)和析构函数(12.4)是特殊的成员函数。 当程序没有明确声明它们时,实现将隐含地声明这些成员函数是一个类类型,除非在12.1中提到。 按照 12.1,12.4和12.8的规定, 实现将隐含地定义它们,如果它们被使用的话 。 程序不应该定义隐式声明的特殊成员函数。 The synthesised ...
-
另一种方法是将AStore和A类移到专用项目并使A类内部的构造函数。 // Project A namespace ProjectA { public class A { public int PropertyOne { get; set; } public string PropertyTwo { get; set; } internal A() {} } public class AStore ...
-
尝试将行更改为: emt = boost::thread(&EmulatorLaunchPluginAPI::launch_emulator_thread, this, cmd, callback)); Try changing the line to: emt = boost::thread(&EmulatorLaunchPluginAPI::launch_emulator_thread, this, cmd, callback));
-
案例1:A类是非POD。 案例2:A类是POD。 a) A a; //This is default initialization b) A a = A(); // This is value initialization Case'1': m将由编译器生成的默认构造函数初始化为某个垃圾值。 情况'2': m将初始化为零,因为A是POD。 您不应该在任何方案中遇到崩溃。 如果你这样做,你可能正在使用破碎的编译器。 有关默认初始化和值初始化的更多详细信息,请参阅此链接 。 Case 1: Class A i ...
-
我的通灵调试技巧告诉我你的Derived继承自Smasher
。 在这种情况下,您对Smasher (*this)调用实际上是调用Smasher的复制构造函数 ,您自己没有删除或定义,因此编译器会很乐意为您生成一个。 调试器几乎肯定不会向您显示正在调用的确切构造函数。 My psychic debugging skills tell me that your class Derived inherits from Smasher . In that case ...