Welcome Guest, Not a member yet? Register   Sign In
When model returns an array of stdClass - how to iterate
#1

(This post was last modified: 06-02-2023, 09:08 AM by Corsari.)

Hello

one kind hint

as you may know I'm not an experienced coder

I have a method in my model that returns an array of stdClass



[Image: array-of-class.jpg]



how should be iterated this ?

the classes are obviously rows of one table from the DB

Thank you for hints and tips


R.
Reply
#2

How do you generate this array?
Show us your code....
Reply
#3

PHP Code:
foreach ($data as $d) {
    // $d is object of stdClass
    // use arrow-notation to get to the stored values by their column names
    // $d->somecolumnname


HTH
Reply
#4

(This post was last modified: 06-03-2023, 01:17 AM by Corsari.)

(06-02-2023, 11:24 AM)sheilaf Wrote:
PHP Code:
foreach ($data as $d) {
    // $d is object of stdClass
    // use arrow-notation to get to the stored values by their column names
    // $d->somecolumnname


HTH
great!

thank you!!!! @sheilaf

I was finding only useless topics (or maybe I was wrongly formulating my searches on the web) where objects where instead associative arrays

So really Thank you, you took away a big headache from me Smile


Though for the sake of completeness

I'm experimenting with HTMX and I have made a live search which now works like a charm
Reply
#5

(This post was last modified: 06-03-2023, 08:25 AM by Corsari.)

And though , it works only disabling development environment

Looks like that XTMX conflicts with the CodeIgniter debug bar

I'll open a new thread about this
Reply




Theme © iAndrew 2016 - Forum software by © MyBB