Created
July 3, 2014 12:22
-
-
Save niraj-shah/a85a740d49e2bed1d53f to your computer and use it in GitHub Desktop.
Parse.com PHP SDK - Using Pointers and ACL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once( 'Parse/parse.php' ); | |
// User ID from User table | |
$user_id = 'QLaLLqjJWi'; | |
// new Profile object | |
$parse = new parseObject('Profile'); | |
// set DOB as date - uses strtotime | |
$parse->dob = $parse->dataType( 'date', '1985-01-01' ); | |
// bio string data | |
$parse->bio = "I am a PHP developer"; | |
// pointer to User table (parse Classes should have _ prefix.) | |
$parse->userId = $parse->dataType( 'pointer', array( '_User', $user_id ) ); | |
// create ACL | |
$acl = new parseACL(); | |
// public cannot read data | |
$acl->setPublicReadAccess( false ); | |
// user can read data | |
$acl->setReadAccessForId( $user_id, true ); | |
// save ACL to object | |
$parse->ACL = $acl->acl; | |
// save object to parse | |
$r = $parse->save(); | |
print_r( $r ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment