How to use the functions of a COM component to save a multi-field recordset in a multidimensional array

Source: Internet
Author: User
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 ();
)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.