On 12-04-02 04:36 PM, Jay Blanchard wrote:
[snip]
function getTiersJson( $company )
{
$tiers = getTiers( $company );
$json = JSON_encode( $tiers );
}
$tiersJson = getTiersJson( 1 );
?>
This will output JSON with the following structure:
[/snip]
OK, now I know I am being dense - but
On Mon, Apr 2, 2012 at 10:36 PM, Jay Blanchard
wrote:
> [snip]
>>> function getTiersJson( $company )
>>> {
>>> $tiers = getTiers( $company );
>>> $json = JSON_encode( $tiers );
>>> }
>>>
>>> $tiersJson = getTiersJson( 1 );
>>>
>>> ?>
>>>
>>> This will output JSON with the following structure
[snip]
>> function getTiersJson( $company )
>> {
>>$tiers = getTiers( $company );
>>$json = JSON_encode( $tiers );
>> }
>>
>> $tiersJson = getTiersJson( 1 );
>>
>> ?>
>>
>> This will output JSON with the following structure:
>>
[/snip]
OK, now I know I am being dense - but don't I have
[snip]
On 3/30/2012 1:14 PM, Robert Cummings wrote:
On 12-03-27 11:11 AM, Jay Blanchard wrote:
[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
>> [-- SNIP --]
Essentially, entries at the root and entries for the children are just
auto indexed array items but the actual entries in those arr
On 12-03-27 11:11 AM, Jay Blanchard wrote:
[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
>> [-- SNIP --]
Essentially, entries at the root and entries for the children are just
auto indexed array items but the actual entries in those arrays retain
the associative index structure for retrie
[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
I think you need two things... the recursive post processor that
removes the string indexes for the children. And then a function that
creates a JavaScript array expression from an object or array. The
question I have for you... is given the f
[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:
I think you need two things... the recursive post processor that
removes the string indexes for the children. And then a function that
creates a JavaScript array expression from an object or array. The
question I have for you... is given the f
On 12-03-26 07:05 PM, Jay Blanchard wrote:
[snip]
On Mar 26, 2012, at 5:58 PM, Robert Cummings wrote:
On 12-03-26 06:52 PM, Jay Blanchard wrote:
[snip]
Did you end up with a satisfactory output? It's not overly difficult to
generate an array instead of an object.
[/snip]
I did for all but
[snip]
On Mar 26, 2012, at 5:58 PM, Robert Cummings wrote:
> On 12-03-26 06:52 PM, Jay Blanchard wrote:
>> [snip]
>>> Did you end up with a satisfactory output? It's not overly difficult to
>>> generate an array instead of an object.
>> [/snip]
>>
>> I did for all but this one instance. Are you
On 12-03-26 06:52 PM, Jay Blanchard wrote:
[snip]
Did you end up with a satisfactory output? It's not overly difficult to
generate an array instead of an object.
[/snip]
I did for all but this one instance. Are you saying that it would be easy to
make of the children arrays? I thought they w
[snip]
> Did you end up with a satisfactory output? It's not overly difficult to
> generate an array instead of an object.
[/snip]
I did for all but this one instance. Are you saying that it would be easy to
make of the children arrays? I thought they were already - am I missing
something?
--
On 12-03-26 05:14 PM, Jay Blanchard wrote:
[snip]
*lol* No worries... it's all about solving problems :)
[/snip]
the other folks who needed to consume the JSON have all done so successfully
today - just this one. The guy who runs it was plenty arrogant when I discussed
with him. He is the on
[snip]
> *lol* No worries... it's all about solving problems :)
[/snip]
the other folks who needed to consume the JSON have all done so successfully
today - just this one. The guy who runs it was plenty arrogant when I discussed
with him. He is the one who wanted me to remove the extra array nam
On 12-03-26 02:12 PM, Jay Blanchard wrote:
[snip]
This is one of "those" projects. It is apparently going to be trying every step
of the way.
[/snip]
I was proven right this morning after all of Robert's good work and what I had
added to make this work. It turns out that the one service who w
[snip]
> Square brackets in JSON represent arrays. Take their JSON, run it through
> json_decode, and assuming it decodes correctly compare the structure to what
> you already have. You should then be able to modify what you have so it
> generates JSON in the format they are expecting.
[/snip]
On 26 Mar 2012, at 19:12, Jay Blanchard wrote:
> [snip]
> This is one of "those" projects. It is apparently going to be trying every
> step of the way.
> [/snip]
>
> I was proven right this morning after all of Robert's good work and what I
> had added to make this work. It turns out that the
[snip]
This is one of "those" projects. It is apparently going to be trying every step
of the way.
[/snip]
I was proven right this morning after all of Robert's good work and what I had
added to make this work. It turns out that the one service who was anxious to
consume the JSON output expect
[snip]
a necessary part of building the structure. It can be removed but only as a
post process. Why does it have to be removed? You can loop through the
structure in JavaScript without paying heed to the key's value.
>
> If it absolutely must go... you need to recurse through the final structur
On 12-03-24 04:11 PM, Jay Blanchard wrote:
[snip]
One more little tweak may be required. The JSON looks like this
{"Executives and Management":{"name":"Executives and Management","children":{
The first part {"Executives and Management": needs to be removed. I think I
know what to do.
[/snip]
[snip]
> One more little tweak may be required. The JSON looks like this
>
> {"Executives and Management":{"name":"Executives and Management","children":{
>
> The first part {"Executives and Management": needs to be removed. I think I
> know what to do.
[/snip]
It has become painfully obvious t
[snip]
> A little tweak here... a little tweak there:
[/snip]
One more little tweak may be required. The JSON looks like this
{"Executives and Management":{"name":"Executives and Management","children":{
The first part {"Executives and Management": needs to be removed. I think I
know what to do
[snip]
> A little tweak here... a little tweak there:
[/snip]
>
>
>if( !isset( $focus[$name] ) )
>{
>$focus[$name] = array
>(
>'name' => $name,
>'children' => array(),
>
On 12-03-24 01:09 PM, Jay Blanchard wrote:
[snip]The crux of it is:
$focus =&$focus[$name];
[/snip]
It works as I expect so far. All I have to do is figure out how to make the
element a name: element in the JSON. for instance an element would look like
this
{
name: "Bob",
child
[snip]The crux of it is:
>
>$focus = &$focus[$name];
> [/snip]
It works as I expect so far. All I have to do is figure out how to make the
element a name: element in the JSON. for instance an element would look like
this
{
name: "Bob",
children: []
}
So the PHP array would have to l
On 12-03-24 08:41 AM, Jay Blanchard wrote:
On Mar 23, 2012, at 11:24 PM, Robert Cummings wrote:
On 12-03-23 05:41 PM, Jay Blanchard wrote:
[-- DELETED GARBAGE --] :)
I just realized... I've been stuck in a thinking rut. I latched onto one
solution that works well in some case but didn't f
On Sat, Mar 24, 2012 at 7:41 AM, Jay Blanchard
wrote:
>
> On Mar 23, 2012, at 11:24 PM, Robert Cummings wrote:
>
>> On 12-03-23 05:41 PM, Jay Blanchard wrote:
>>> [-- DELETED GARBAGE --] :)
>>
>> I just realized... I've been stuck in a thinking rut. I latched onto one
>> solution that works well
On Mar 23, 2012, at 11:24 PM, Robert Cummings wrote:
> On 12-03-23 05:41 PM, Jay Blanchard wrote:
>> [-- DELETED GARBAGE --] :)
>
> I just realized... I've been stuck in a thinking rut. I latched onto one
> solution that works well in some case but didn't fully examine the nuances of
> your o
[snip]
> Did you send me a sample dump for your table :)
[/snip]
I'll do that today. I got side-tracked last night.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On 12-03-23 05:41 PM, Jay Blanchard wrote:
[-- DELETED GARBAGE --] :)
I just realized... I've been stuck in a thinking rut. I latched onto one
solution that works well in some case but didn't fully examine the
nuances of your own scenario. Given the way you are creating your
hierarchy you w
On 12-03-23 05:26 PM, Jay Blanchard wrote:
[snip]
$item['children'] should be an array, somehow a string has been assigned :/
[/snip]
Yep. I am trying to figure that out now. I'm sure it is something really small.
[/snip]
I have been hammering away at it for a while now and still cannot find
[snip]
…stuff….
[/snip]
For those interested here is where the problem seems to occur -
$child = array
(
'id' => $id,
'parentId' => $pid,
'children' => array()
);
$children
> [snip]
>> $item['children'] should be an array, somehow a string has been assigned :/
> [/snip]
>
> Yep. I am trying to figure that out now. I'm sure it is something really
> small.
[/snip]
I have been hammering away at it for a while now and still cannot find the
issue. I'll push away for a
[snip]
> $item['children'] should be an array, somehow a string has been assigned :/
[/snip]
Yep. I am trying to figure that out now. I'm sure it is something really small.
BTW, after making the change to the for loop there are results returned as we
expected.
--
PHP General Mailing List (http:
On 12-03-23 03:52 PM, Jay Blanchard wrote:
[snip]
SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and
Management','Professionals','Technicians','Craft
Workers-Skilled','Operatives','Contractor','Sales Wor
> [snip]
> SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM
> `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and
> Management','Professionals','Technicians','Craft
> Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and
> Helpers','Ad
[snip]
> No, I'm performing assignment... intentionally. Parent's becomes the previous
> children to move down a level. The following:
>
>if( !($parents = &$children) )
>
> performs assignment and an empty array check in one statement.
[/snip]
Gotcha'.
So all I am ever getting back right
[snip]
> Did you get any results form the database on the second run through the query
> loop?
[/snip]
Actually, no. I just ran the raw query -
SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and
Managem
On 12-03-23 03:28 PM, Jay Blanchard wrote:
On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:
On 12-03-23 03:17 PM, Jay Blanchard wrote:
[snip]
$json = JSON_encode( $root );
[/snip]
Update on my test. This works perfectly Robert - thank you very much! But there
is one small problem t
On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:
> On 12-03-23 03:17 PM, Jay Blanchard wrote:
>> [snip]
>>>$json = JSON_encode( $root );
>> [/snip]
>>
>> Update on my test. This works perfectly Robert - thank you very much! But
>> there is one small problem that I am trouble-shooting: it
On 12-03-23 03:22 PM, Jay Blanchard wrote:
[snip]
$json = JSON_encode( $root );
[/snip]
Update on my test. This works perfectly Robert - thank you very much! But there
is one small problem that I am trouble-shooting: it only goes one layer and
doesn't progress any further. I suspect it
On 12-03-23 03:17 PM, Jay Blanchard wrote:
[snip]
$json = JSON_encode( $root );
[/snip]
Update on my test. This works perfectly Robert - thank you very much! But there
is one small problem that I am trouble-shooting: it only goes one layer and
doesn't progress any further. I suspect it i
> [snip]
>> $json = JSON_encode( $root );
> [/snip]
>
> Update on my test. This works perfectly Robert - thank you very much! But
> there is one small problem that I am trouble-shooting: it only goes one layer
> and doesn't progress any further. I suspect it is on this section of code
> that
[snip]
>$json = JSON_encode( $root );
[/snip]
Update on my test. This works perfectly Robert - thank you very much! But there
is one small problem that I am trouble-shooting: it only goes one layer and
doesn't progress any further. I suspect it is on this section of code that I am
going to
On 12-03-23 02:08 PM, Jay Blanchard wrote:
[snip]
Your data structure doesn't appear to be very ummm normalized... Nonetheless,
the following should do it:
[/snip]
You're absolutely correct. Unfortunately I am not the designer and cannot
really do anything about it. I just have to work with
[snip]
> Your data structure doesn't appear to be very ummm normalized... Nonetheless,
> the following should do it:
[/snip]
You're absolutely correct. Unfortunately I am not the designer and cannot
really do anything about it. I just have to work with what I have. Thank you
very much for this
On 12-03-22 03:54 PM, Jay Blanchard wrote:
[snip]
At one point you indicated all the data was coming from one table. Can you send
me the table fields and indicate which fields are used to determine parent
child relationship? Also 2 sample rows of data which have a relationship would
be helpfu
[snip]
> At one point you indicated all the data was coming from one table. Can you
> send me the table fields and indicate which fields are used to determine
> parent child relationship? Also 2 sample rows of data which have a
> relationship would be helpful.
[/snip]
Columns - tier1, tier2, ti
On 12-03-22 01:06 PM, Jay Blanchard wrote:
On 3/22/2012 11:40 AM, Robert Cummings wrote:
What's the field for which you are selecting data? I've written this
up as a parent/child relationship but it works for data/sub-data
relationships also.
SELECT itemId, otherData FROM table WHERE "some cond
On 3/22/2012 11:40 AM, Robert Cummings wrote:
On 12-03-22 12:34 PM, Jay Blanchard wrote:
[snip]
Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say "Select the children" I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. Thi
On 12-03-22 12:34 PM, Jay Blanchard wrote:
[snip]
Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say "Select the children" I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. This
is why we build the array of parent IDs (also
[snip]
Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say "Select the children" I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. This
is why we build the array of parent IDs (also I wrote build an array
of "child IDs", i
[snip]
On 3/22/2012 11:17 AM, Robert Cummings wrote:
On 12-03-22 11:58 AM, Jay Blanchard wrote:
[snip]
Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:
On 12-03-22 11:58 AM, Jay Blanchard wrote:
[snip]
Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:
1. Select your root elements.
2. Loop over i
On 12-03-22 11:58 AM, Jay Blanchard wrote:
[snip]
Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:
1. Select your root elements.
2. Loop over i
[snip]
Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:
1. Select your root elements.
2. Loop over in PHP and create an array of child IDs.
On 12-03-22 11:28 AM, Jay Blanchard wrote:
[snip]
...stuff...
[/snip]
Here is the explanation for what I have done and what I am trying to do
- (based on the customer's request).
A week or so ago I took a set of queries from one table and made them
into an unordered list. This will be pseudo-co
[snip]
...stuff...
[/snip]
Here is the explanation for what I have done and what I am trying to do
- (based on the customer's request).
A week or so ago I took a set of queries from one table and made them
into an unordered list. This will be pseudo-code so that you get idea.
SELECT DISTINC
On Mar 21, 2012, at 3:45 PM, Daniel Brown wrote:
>
>I would, yes, but that's not the point. Is Anna single? I'm
> ready to trade Debs in for a newer model.
>
> --
>
Ah... to be young again. But, on the other hand, they have so much to learn. :-)
Cheers,
tedd
_
tedd
[snip]
Would it not be easier to get the data from a view which has the tables joined?
Then it would be one query and it's a simple matter to format the results into
the multi dimensional array then json?
[/snip]
The data is all from one table. I'll write up a more thorough explanation in a
lit
On 2012-03-21, at 2:39 PM, Jay Blanchard
wrote:
> This is a continuation of the nested query thing I posted to the list a while
> back. I was finally able to output a nested unordered array that worked out
> well, but scope-creep has come in the door and I have to change gears.
>
> I have a
On 12-03-21 04:42 PM, Jay Blanchard wrote:
[snip]
Why are you trying to create the JSON structure in parts? When I have nesting
like this i build the full nested structure as PHP, then export to JSON.
[/snip]
As PHP? An array?
Yeah sorry... you know what I meant ;)
Cheers,
Rob.
--
E-Mail D
On 03/21/2012 11:39 AM, Jay Blanchard wrote:
If you were me would you just generate the JSON? If not what is he best way to
output an array that will nest properly for each subsequent query?
Depends on where the data is coming from and how you are retrieving it from.
Can you provide examples
[snip]
> Why are you trying to create the JSON structure in parts? When I have nesting
> like this i build the full nested structure as PHP, then export to JSON.
[/snip]
As PHP? An array?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On 12-03-21 03:52 PM, Jay Blanchard wrote:
[snip]
I would, yes, but that's not the point. Is Anna single? I'm
ready to trade Debs in for a newer model.
[/snip]
I'm thinking that Debs would upset your array if you traded her in.
Anyhow, I have spent the last hour trying to output valid J
[snip]
>I would, yes, but that's not the point. Is Anna single? I'm
> ready to trade Debs in for a newer model.
[/snip]
I'm thinking that Debs would upset your array if you traded her in.
Anyhow, I have spent the last hour trying to output valid JSON but the whole
thing is making me barki
On Wed, Mar 21, 2012 at 14:39, Jay Blanchard
wrote:
[snip!]
> I ran it through json_encode() and got the following output
>
> {"John":{"email":"j...@demo.com","website":"www.john.com","age":"22","password":"pass","description":{"hair":"blonde","eyes":"blue","build":"medium"}},"Anna":{"email":"a...
On Wed, Mar 21, 2012 at 2:39 PM, Jay Blanchard
wrote:
> ...
> I have a project where I have multiple queries and each query uses the
> results from the previous query to get it's results. I need to do one of two
> things, either out put a multidimensional array that I can use json_encode()
> on
This is a continuation of the nested query thing I posted to the list a while
back. I was finally able to output a nested unordered array that worked out
well, but scope-creep has come in the door and I have to change gears.
I have a project where I have multiple queries and each query uses the
68 matches
Mail list logo