It is currently Thu Mar 28, 2024 9:55 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Laravel get JSON array from database
PostPosted: Fri Oct 07, 2022 5:09 am 
Newbie
Newbie

Joined: Wed Jul 13, 2022 11:40 am
Posts: 2
What is the best way in Laravel to store an array in your database? And how do I get the same array with a query?

I have a variable that's an array in an array:

$colors = array(array('green'), array('yellow', 'white'));
When I store $colors, my database (column type = json) save it as:

[["green"], ["yellow", "white"]]
But when I try to get it from a query, I couldn't get the same array as $colors.

My query:

$colors = DB::table('colors')
->where('id', '1')
->value('arraycolors');
I hope someone can help how to query an array. Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Laravel get JSON array from database
PostPosted: Sat Oct 08, 2022 4:18 pm 
Site Admin

Joined: Sat May 31, 2008 1:56 am
Posts: 497
Hello

Search online for Laravel-specific forums for your requests. We do not offer script development or debugging and the forum is intended only for our system services.
Thank you for your understanding on this matter.

_________________
Best Regards,
Miles
ModeratorsTeam
Freehostia.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011