parse.com-php-library
parse.com-php-library copied to clipboard
what about column with type "object" ?
I want to update a column of type "object" in my table, with: {"0":{"end":"1:00","start":"12:00"}, "1":{"end":"1:00","start":"12:00"}, "2":{"end":"1:00","start":"12:00"}, "3":{"end":"1:00","start":"12:00"}, "4":{"end":"1:00","start":"12:00"}, "5":{"end":"1:00","start":"12:00"}, "6":{"end":"1:00","start":"12:00"}}
but every time I get error like: "invalid type for key ....., expected object, but got string" (if I use json_encode) or " invalid type for key ....., expected object, but got array"..
HELP PLEASE!!!!
:)
Could you provide some php code so we can help figure out why this is not working?
Hi!
I mean: If i want to set my column to {"0":{"end":"10:00","start":"17:00"}, "1":{"end":"12:00","start":"15:00"}}
it should be created like dictionary..I guess..so I use arrays:
$openeing_hours["0"] = array ("start"=>"10:00:","end"=>"17:00"); $openeing_hours["1"] = array ("start"=>"12:00:","end"=>"15:00"); $openeing_hours = json_encode($openeing_hours);
$parse = new parseObject("Store"); $parse->__set("opening_hours",$opening_hours); <------this fails. Column is "Object". What should I send here instead?
(parse.com error: invalid type for key opening_hours, expected object, but got string)
Just to mention, I'm not the owner of the DB, so I really can't change the column type.
Thanks.
Alona
I too am interested in this. I need to add misc data to a row so I added a column of type object to handle it, but apparently this library doesn't like doing as alonam has suggested.
That's strang because I saw one friend of mine, using Python...and succesfully updated object type with JSON..so I don't get it..If someone knows the answer...it may help a lot!
BTW, in linux it should be :$opening_hours = json_encode($opening_hours,JSON_FORCE_OBJECT); to let it be non associative array as object...
Hey @alonam, my library is actually already running json_encode on things, so this could be the problem. Can you try just setting opening_hours to be just your array?
Already tried it.. that give's me the error: parse.com error: invalid type for key opening_hours, expected object, but got array (if I leave the array as it is, with no json_encode...)
SO...I now tried to change your line : $postData = json_encode($args['data']); ----> $postData = json_encode($args['data'],JSON_FORCE_OBJECT); and..IT WORKS! But...only for objects type...for columns of array type..it fails. Now I really don't know what to do.
@alonam that means I need to make a change in the library to account for this.
Thanks...maybe in the meantime I'll ask for changing the col to array..Hope it's not too complicated...
A work around for now is to make your column type array then you can make the first index an object and it works fine.
$parse->something = array('{test:2}');
It's what I'm doing until it has been resolved.
M
Great to hear, I'll still keep this on my radar to get both arrays and object types working correctly.
hi.. Unfortunately, I can't change the column type...because android app already uses the parse table.. So until the change of your API, I'll make another workaround outside the library...(only for save and update..).
thanks @thedangler @apotropaic