Laravel 5.2从MySQL中的任何表单字段返回int值。例如,在此方法中,我有一个varchar格式为6271403119的大数字:
static public function gawUser($userid = null, $filed = 'id')
{
if (Empty($userid)) $userid = Auth::user()->id;
$user = Gaw_user::where('user_id', $userid)->first();
if (!empty($user)) return $user->$filed;
else return false;
}
}返回2147483647
发布于 2016-06-08 14:12:34
确保你的Gaw_user模型禁用了递增,否则eloquent会假设你的id是一个自动递增的整数。
class Gaw_user extends Eloquent
{
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
...
}https://stackoverflow.com/questions/37693916
复制相似问题