__toString()魔术方法的调用
这个魔术方法(magic method
),本质上是把一个Object转为String,其实是可以是override,实现自己的逻辑的。
补充解释一下:
为什么写这个没头没脑的文章呢?
我今天在用一个PHP的JWT的库,https://github.com/lcobucci/jwt
就先不说里面的一个配置没有文档容易写错吧,就说返回值:
这个魔术方法(magic method
),本质上是把一个Object转为String,其实是可以是override,实现自己的逻辑的。
补充解释一下:
为什么写这个没头没脑的文章呢?
我今天在用一个PHP的JWT的库,https://github.com/lcobucci/jwt
就先不说里面的一个配置没有文档容易写错吧,就说返回值:
$model->save()
的时候,如果不符合rules,会导致保存失败,但不抛出异常,所以这个时候,就需要看一下是不是rules设置的问题,所以可以这样做:
$model->save(false)
这样做,就是绕过了rules里对数据的validation,首先保证了,你对数据库的CRUD是成功的,代码是OK的,然后再看,是否是数据的问题。
Statements That Cannot Be Rolled BackSome statements cannot be rolled back. In general, these include data definition language (DDL) statements, such as those that create or drop databases, those that create, drop, or alter tables or stored routines.
You should design your transactions not to include such statements. If you issue a statement early in a transaction that cannot be rolled back, and then another statement later fails, the full effect of the transaction cannot be rolled back in such cases by issuing a ROLLBACK statement.
这个是摘自MySQL文档,8.0和5.7都是同样的文档。但据说PostgreSQL
没有这样的问题,还没测试。
我理解就是,tag
就是一个快照(snapshot),是某个repo的一个定点的状态;branch
就是一段录像,反应了一段时间范围内的变化(多个commit组成了一个开发变化的过程)。
A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base. Changes to a branch may eventually be merged back into another branch to unify them.
From the theoretical point of view:
毕竟有时不总是需要有持久化的,比如登录,当然需要,但其他的时候,基本上都只是一个瞬时状态。
云计算的优点真的不用再多讲,但就没缺点了吗?当然有。
比如,我最近在使用Netlify Identity
,这个服务的一个最大的有点非常OK的,但缺点也很明显嘛,因为有一个在localStorage里,有一个key/value键值对,key是gotrue.user
,value是一个多层嵌套的json字符串,那么由于多层嵌套,一不小心就会报错,比如忘记序列化、忘记把字符串再解析为json等。
更重要的是,这条key/value记录,CRUD等操作都是由Netlify Identity Widget
来操作,这就违背了store的一个重要理念:single source of truth
。那么这怎么办?