php5.4 uses COM to connect to the PhD database, this database is special, the table name, the field is not good to write, is Honeywell's database. COM query returns multiple records, and many fields, I want to do arithmetic operations on a field, do not know how to operate, I novice, internet check data said to be the record set into a multidimensional array, suffer not PHP, please help the master! Thank you!
I make an analogy, query 0601 class of student achievement, return many records, each record contains: class, student number, name, subject (language), result field. How to use COM component functions to save a recordset to a multidimensional array, simply manipulating an array, I almost will.
$conn = new COM ("ADODB. Connection ");
$connstr = "... A little ";
$conn->open ($CONNSTR);
$starttime = "2014-03-20 08:30:00";
$sql = "Select Banji,sno,name,kemu,chengji from STU_CJ WHERE banji= ' 0601 ' and kemu= ' Yuwen '";
$stmt = $conn->execute ($sql);
Here's how to use COM functions to store a recordset $stmt into a multidimensional array and manipulate the array
Reply to discussion (solution)
I don't know what the PhD database is.
But since you can use ADODB. Connection connection, obviously there's no big problem.
Can write
$stmt = $conn->execute ($sql), while (! $stmt->eof) { $res [] = Arraay ( ' banji ' = = $stmt->fields[' Banji ']->value, ' sno ' = $stmt->fields[' sno ']->value, ' name ' and ' = ' $stmt->fields[' name '- >value, ' kemu ' = ' $stmt->fields[' Kemu ']->value, ' chengji ' = $stmt->fields[' Chengji ']- >value, ); $stmt->movenext ();}
In short, with the ASP's writing basically consistent
Also can be written with OBCD function group to operate
Thank you very much for your answer and learn new knowledge.
I have another problem, after you have been instructed to successfully store the query's recordset into an array, but if more than one class, a class query to get an array, you can again the class name, and each class query to get the array together in an array? I do not know that I understand no, that is, such as 0601 classes, and res[];0602 class and res[] ... stored in the array. Class different to get the res different, want to put them together in an array, how to do, and how to reference a value
Array
' 0601 class ' = = Array ();
' 0602 class ' = = Array ();
)