in Education by
So like when working with mysql_fetch_object(), how do you do things like this: $array = array(); while($row = mysql_fetch_object($result)) { $array[] = $row; } How do you accomplish that with objects instead of an array? Like, $object = new stdClass; while($row = mysql_fetch_object($result)) { $object[] = $row; } Is there a way to do this without a lot of ugly typecasting? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The first method is correct, it should assign all the objects into $array, like an array, you can access via $arr[0]->$COLUMN ... I bet you are not referring to this :- $object = new stdClass; while($row = mysql_fetch_object($result)) { $props = "object_{$cnt}"; $object->$props = $row; ++$cnt; } The second method is assign each object into property of $object, and you can assign the property as :- $object->object_0->$COLUMN ...

Related questions

0 votes
    Background: I have an old web CMS that stored content in XML files, one XML file per page. I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    How to dynamically allocate a 1D and 2D array in c?...
asked Jan 24, 2021 in Technology by JackTerrance
0 votes
    I currently have 2 classes: workerListClass workerClass The workerListClass gets a list of work with ids from ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What happens if you add your just created object to a mutable array, and you release your object?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    how would i add multiple buttons to a window in c#? here's what i need to do... i'm getting ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I have a field call query_data defined as text in my MySQL database. In my model I defined this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    How to add an element into an Array?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    I have a dataset that only contains y-values in one column. I want to insert a column of x- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    How can I apply my div position x value to a variable? And how to iterate it in a for loop? ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 21, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I would like to dynamically assign a class to a specific cell in a table. An object in "cols" ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    In my Android Application I want to create a bunch of ConstraintLayouts where each has for example an ImageView and a TextView ... .LayoutParams cparams.setMargins(4, 4, 4, 4) //...
asked May 7, 2022 in Education by JackTerrance
0 votes
    i'm working on an app for language studying. I want to display the translations directly underneath the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I'm trying to implement a functionality that can determine which word in the text the user clicked on. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
...