How to use the functions of the com component to store the multi-field record set in the multi-dimensional array php5.4 use com to connect to the phd database. This database is special, and the table name and field are not easy to write. it is a database of honeywell. Com query returns multiple records and multiple fields. I want to perform arithmetic operations on a field and do not know how to operate it. I am a newbie, online data query indicates that records are stored in multi-dimensional arrays, so php is not supported. please help me! Thank you!
For example, to query the scores of students in the 0601 class, multiple records are returned. each record contains the class, student ID, name, subject (language), and score fields. How to use the com component function to save the record set to a multi-dimensional array, just operate on the array, I will almost.
$ Conn = new COM ("ADODB. Connection ");
$ Connstr = "... omitted ";
$ Conn-> Open ($ connstr );
$ Starttime = "08:30:00 ";
$ SQL = "Select banji, sno, name, kemu, chengji FROM stu_cj WHERE banji = '000000' AND kemu = 'yuwen '";
$ Stmt = $ conn-> Execute ($ SQL );
How to use the com function to store the record set $ stmt to a multi-dimensional array and operate the array
Reply to discussion (solution)
I don't know what the phd database is.
However, since we can use ADODB. Connection to connect, there is obviously no big problem.
Able to write
$stmt = $conn->Execute($sql);while(! $stmt->eof) { $res[] = arraay( 'banji' => $stmt->fields['banji']->value, 'sno' => $stmt->fields['sno']->value, 'name' => $stmt->fields['name']->value, 'kemu' => $stmt->fields['kemu']->value, 'chengji' => $stmt->fields['chengji']->value, ); $stmt->MoveNext();}
In short, it is basically the same as asp.
You can also use the obcd function group to perform operations.
Thank you very much for your answers and new knowledge.
I encountered another problem. after your instruction, you successfully stored the queried record set in the array. However, if multiple classes and one class have an array after the query, can I store the class name together with the array queried by each class in an array? I don't know. I don't know. it's just like class 0601, and res []; class 0602 and res []. And save it to the array. Different classes get different res. they want to store them together in an array, how to do it, and how to reference a value.
Array (
'1970 class' => array ();
'1970 class' => array ();
)