$results = $query->find(); $result = $results[0]; //get garden sensors list $sensors = $result->get("pName"); echo "<br>We are expecting these sensors: " . $sensors; /* assign sensor values based on above sensor list for ($i = 0; $i < count($sensors); $i++) { $object = $sensors[$i]; echo $object; } */ //assemble sensor array function arrayize($input) { return array_map('intval', array_filter(explode(",", $input), 'is_numeric')); } //$currentReadings = preg_split("\"", $reading = new ParseObject("Reading"); $reading->set("gardenID", $result); $reading->setArray("readings", [arrayize($airTemp), arrayize($hum), arrayize($waterTemp), arrayize($sun), arrayize($wet), arrayize($waterPH)]); try { $reading->save(); echo '<br>New reading created with objectId: ' . $reading->getObjectId() . '<br>'; } catch (ParseException $ex) { // Execute any logic that should take place if the save fails. // error is a ParseException object with an error code and message. echo 'Failed to create new object, with error message: ' . $ex->getMessage(); }
private function isDBRecordEditable() { return in_array(Session::currentPerson()->getID(), arrayize($this->getOwnerID())) || Session::defaultPosition() >= POSITION_ADMIN; }
/** * Enforces that true === array_key_exists($key,$arr) * * @param string $key * @param array $arr */ function debug_enforce_key_exists($key, $arr) { arrayize($key); debug_enforce(array_all($key, function ($key) use($arr) { return array_key_exists($key, $arr); }), "Expected key(s) '" . implode(',', $key) . "' does not exists."); }
/** * @param $array * @return array */ function array_flatten_recursive($array) { $array = array_map_val($array, function () { $array = func_get_args(); $array = array_shift($array); return arrayize($array); }); return array_reduce($array, 'array_merge_recursive'); }
/** * @param string|array $key * @return mixed * @throws Exception */ public function settingsGet($key = []) { arrayize($key); debug_enforce(array_all_dg(is_type_dg('string')), "Invalid setting key " . var_dump_human_compact($key)); $current =& $this->_settings; while (!empty($key)) { debug_enforce_type($current, 'array'); $part = array_shift($key); $current =& $current[$part]; } return $current; }
function unregister_sidebars($sidebars) { $GLOBALS['_unregister_sidebars'] = arrayize($sidebars); }
/** * @static * @param array $conditions * @param array|callable|null $constructor * * @return Lib_Model_Set */ public static function getSetBy($conditions, $constructor = null) { $model = static::find()->filterBy($conditions); if (null === $constructor) { $constructor = array_keys($model->recordColumnsGet()); } if (is_callable($constructor)) { $constructor($model); } else { arrayize($constructor); $model->setColumns($constructor); } return $model->loadSet(); }
public function joins() { return arrayize($this->joins); }
/** * @param string $name * @param mixed $value * @return string */ function mime_header_entry_map($value, $name) { if (debug_assert(is_string($name), "Invalid parameters ")) { switch ($name) { case 'Content-Type': arrayize($value); $value = mime_header_contenttype_map($value[0], array_filter_key($value, tuple_get(1, 'is_string'))); break; case 'Content-Disposition': $value['name'] = mime_header_encode($value['name']); $value = mime_header_contenttype_map($value[0], array_filter_key($value, tuple_get(1, 'is_string'))); break; default: $dump = var_dump_human_compact($value); debug_enforce(is_string($value), "Could not map '{$name}'=>'{$dump}'"); break; } return "{$name}: {$value}\r\n"; } else { return ''; } }
public function setColumns($cols = '*', $correlationName = null) { if ($cols === '*') { $cols = array_keys($this->schemaColumnsGet()); } arrayize($cols); foreach ($cols as $key => $val) { if ('id' === $key) { unset($cols[$key]); $cols[$this->getPrimaryKey()] = $val; } } if (null === $correlationName) { $correlationName = $this->getAlias(); } $this->getSelect()->setFields($cols, $correlationName); return $this; }