laravel how to access column with number name of a table?

后端 未结 12 1294
闹比i
闹比i 2020-12-18 19:11

I make a table with number 22 as the column name. How to access this column?

content:

I\'ve tryed thest

$obj = Tablename::f         


        
12条回答
  •  醉酒成梦
    2020-12-18 19:58

    You can use the following syntax, as found in the variable variables topic in the PHP documentation:

    $obj->{'22'};
    

    ...

    Curly braces may also be used, to clearly delimit the property name. They are most useful when accessing values within a property that contains an array, when the property name is made of mulitple parts, or when the property name contains characters that are not otherwise valid (e.g. from json_decode() or SimpleXML).

提交回复
热议问题