Suppose that I have a database query which looks like below -
select name, gender, birthday from person where person_id = 1;
When this query is executed, some records from the database is returned. I want to execute this query inside a function, then make a custom object which will contain the exact attributes as the column names, with the corresponding values. As an example, suppose that the object is X. So it will have three attributes which are X->name, X->gender and X->birthday, with the corresponding values from the records.
As a second example, consider the following query -
select test1, test2, test3 from test where test_id = 1;
I want to execute this query inside the same function and using the same method, then generate a custom-object Y which will contain the attributes Y->test1, Y->test2 and Y->test3.
Is it doable in PHP? If so, then how?
Edit: By custom object, I meant any kind of object. It does not need to be an instance of a specific class or something like that. I just want to return an object from that function so that I can populate the appropriate classes from the returned object's property values.