Thinkphp 3.2
$use=D('classone');$db=$use->select(5);$arr = $db[0] ? $db[0] : '';foreach($arr as $key => $value){ $arrKey[] = $key;}
This, I took the name of the field to get into an array $arrKey, but I think this method is rather stupid, there should be a direct access to the method, I ask there is no???
Reply content:
Thinkphp 3.2
$use=D('classone');$db=$use->select(5);$arr = $db[0] ? $db[0] : '';foreach($arr as $key => $value){ $arrKey[] = $key;}
This, I took the name of the field to get into an array $arrKey, but I think this method is rather stupid, there should be a direct access to the method, I ask there is no???
Tp5?
/** * Get data table information * @access public * @param string $tableName data table name empty automatically get * @param string $fetch get information types including fie LDS type bind PK * @return Mixed */Public function gettableinfo ($tableName = ', $fetch = ') {stat IC $_info = []; if (! $tableName) {$tableName = $this->gettable (); } if (Is_array ($tableName)) {$tableName = key ($tableName)?: current ($tableName); } if (Strpos ($tableName, ', ')) {//Multiple tables do not get field information return false; } $GUID = MD5 ($tableName); if (!isset ($_info[$guid])) {$info = $this->connection->getfields ($tableName); $fields = Array_keys ($info); $bind = $type = []; foreach ($info as $key = + $val) {//record field type $type [$key] = $val [' type ']; if (Preg_match ('/(int|double|float|decimal|real|numeric|serial)/is ', $val [' type '])) {$bind [$Key] = PDO::P aram_int; } elseif (Preg_match ('/bool/is ', $val [' type '])) {$bind [$key] = PDO::P aram_bool; } else {$bind [$key] = PDO::P aram_str; } if (!empty ($val [' primary '])) {$PK [] = $key; }} if (Isset ($PK)) {//Set Primary KEY $PK = count ($PK) > 1? $PK: $pk [0]; } else {$pk = null; } $result = [' Fields ' + $fields, ' type ' and ' $type, ' bind ' = ' $bind, ' PK ' + $PK]; $_info[$guid] = $result; } return $fetch? $_info[$guid] [$fetch]: $_info[$guid]; }
Summarize thinkphp Quick Query Getby, GetField, Getfieldby usage and scenes http://baijunyao.com/article/59