Joak Posted February 19, 2014 Share Posted February 19, 2014 Hello guys I Have to try to build an array that has a tree structure(4 levels), but I have gotten an error when I tried to put the 2 level ... commands out of sync; you can't run this command now. I attached a file with the code, what's wrong? Regards. code.txt Quote Link to comment https://forums.phpfreaks.com/topic/286332-json-commands-out-of-sync-you-cant-run-this-command-now/ Share on other sites More sharing options...
requinix Posted February 20, 2014 Share Posted February 20, 2014 Without downloading and looking at your code I'm going to say If you use unbuffered queries, with PDO or mysqli or whatever, then you have to completely read one query's results before you can run another. In rough order of preference your solutions are: 1. Use JOINs to get all the data you need at once without having to issue queries inside loops. A little bit more work but gives much better performance. 2. Use buffered queries. The alternative in case you can't get #1 to work. (I say "the alternative" because #3 is so bad you shouldn't even consider it.) 3. Keep the unbuffered queries but read out all the data into a temporary array and loop over that. Also known as "doing buffered queries the wrong way". Quote Link to comment https://forums.phpfreaks.com/topic/286332-json-commands-out-of-sync-you-cant-run-this-command-now/#findComment-1469590 Share on other sites More sharing options...
Joak Posted February 20, 2014 Author Share Posted February 20, 2014 Hello Requinix. Oks, If I get all the data with one query (no problem, in fact I started with one query) ... how can i build a tree structure array? Quote Link to comment https://forums.phpfreaks.com/topic/286332-json-commands-out-of-sync-you-cant-run-this-command-now/#findComment-1469714 Share on other sites More sharing options...
kicken Posted February 20, 2014 Share Posted February 20, 2014 how can i build a tree structure array? Building tree structures in PHP using references Quote Link to comment https://forums.phpfreaks.com/topic/286332-json-commands-out-of-sync-you-cant-run-this-command-now/#findComment-1469716 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.