Last active
August 29, 2015 14:16
-
-
Save pgorrell/341693e421a36573ef06 to your computer and use it in GitHub Desktop.
List of object types and how to insert into parse from php sdk.
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 | |
$resort_qry = "SELECT | |
res_id | |
,resort as name | |
,res_about as description | |
,res_state as state | |
,x(res_map_point) AS lat | |
,y(res_map_point) AS lng | |
,created_date | |
,'dsadafe,dseaDS12d' as concat_str | |
FROM | |
resorts | |
WHERE | |
res_id in (1,2,3)"; | |
$results = $enviro->conn->db->Execute($resort_qry); | |
while($row = $results->FetchRow()) { | |
try{ | |
$parse = ParseObject::create("resort"); | |
//Load a string | |
$parse->set("resort_name", $row['name']); | |
//Load a number | |
$parse->set("resort_id", intval($row['res_id'])); | |
//Load a geolocation | |
$point = new ParseGeoPoint(setParseFloatFormat($row['lat']), setParseFloatFormat($row['lng'])); | |
$parse->set("location", $point); | |
//Load a Date | |
$exp_date = new DateTime($row['created_date']); | |
$parse->set("expireDate",$exp_date); | |
//Load a boolean | |
$parse->set("flag", true); | |
//Load an array | |
$list = explode(",",$row['concat_str']); | |
$parse->setArray("arrayList", $list); | |
//Load a pointer | |
$parentObj = new ParseObject("testofObject", "tcrxhw9WIA"); | |
$parse->set("testObjectId",$parentObj); | |
$parse->save(); | |
}catch(ParseException $ex){ | |
echo $ex->getCode(); | |
echo $ex->getMessage(); | |
} | |
$new_resort_parse_id = $parse->getObjectId(); | |
$upd_res_qry = "UPDATE resorts SET resortObjectId = ? WHERE res_id = ?"; | |
$upd_result = $enviro->conn->db->Execute($upd_res_qry, array($new_resort_parse_id, $row['res_id'])); | |
}?> |
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 | |
$resort_qry = "SELECT | |
res_id | |
,resort as name | |
,res_about as description | |
,res_state as state | |
,x(res_map_point) AS lat | |
,y(res_map_point) AS lng | |
,created_date | |
,'dsadafe,dseaDS12d' as concat_str | |
FROM | |
resorts | |
WHERE | |
res_id in (1,2,3)"; | |
$results = $enviro->conn->db->Execute($resort_qry); | |
while($row = $results->FetchRow()) { | |
try{ | |
$parse = ParseObject::create("resort"); | |
//Load a string | |
$parse->set("resort_name", $row['name']); | |
//Load a number | |
$parse->set("resort_id", intval($row['res_id'])); | |
//Load a geolocation | |
$point = new ParseGeoPoint(setParseFloatFormat($row['lat']), setParseFloatFormat($row['lng'])); | |
$parse->set("location", $point); | |
//Load a Date | |
$exp_date = new DateTime($row['created_date']); | |
$parse->set("expireDate",$exp_date); | |
//Load a boolean | |
$parse->set("flag", true); | |
//Load an array | |
$list = explode(",",$row['concat_str']); | |
$parse->setArray("arrayList", $list); | |
//Load a pointer | |
$parentObj = new ParseObject("testofObject", "tcrxhw9WIA"); | |
$parse->set("testObjectId",$parentObj); | |
$parse->save(); | |
}catch(ParseException $ex){ | |
echo $ex->getCode(); | |
echo $ex->getMessage(); | |
} | |
$new_resort_parse_id = $parse->getObjectId(); | |
$upd_res_qry = "UPDATE resorts SET resortObjectId = ? WHERE res_id = ?"; | |
$upd_result = $enviro->conn->db->Execute($upd_res_qry, array($new_resort_parse_id, $row['res_id'])); | |
}?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment