How does thinkphp traverse the query results? I traverse the query results in the controller and then do some processing.
$ SQL = "select CC from XXX ";
$ Db = M ();
$ Rs = $ db-> query ($ SQL); // traverse RS
Foreach ($ rs as $ key => $ value)
{
// Obtain the value of the "CC" field for each record
$ CC = $ value; // failed!
$ CC = $ value [1]; // failed!
$ CC = $ value [0]; // failed!
$ CC = ?? /// // Help !!!!!
}
Foreach ($ rs as $ value)
{
// Obtain the value of the "CC" field for each record
$ CC = $ value; // failed!
$ CC = $ value [1]; // failed!
$ CC = $ value [0]; // failed!
$ CC = ?? /// // Help !!!!!
}
Reply to discussion (solution)
$ Rs = $ db-> query ($ SQL); // traverse RS
Print_r ($ rs );
Post result
Array (33 )(
[0] => array (1 )(
[Column_name] => (string) ID
)
[1] => array (1 )(
[Column_name] => (string) UserName
)
[2] => array (1 )(
[Column_name] => (string) PSW
)
[3] => array (1 )(
[Column_name] => (string) NickName
)
Print does not know where to view the results. move the mouse to display the values of these items.
My statement is to query the names of all columns in a table, and then extract the names and then process them.
Foreach ($ rs as $ value)
{
Echo $ value ['column _ name'];
}
OK. thank you!