/** * Return data from handler in JSON format. * @param array $data * @return string */ private function toJSON($data = array()) { if ($this->success) { $this->message = $this->resource->getOnSuccessMessageFor($this->serviceName); } $ret = array('success' => $this->success, 'message' => $this->message, 'code' => $this->code, 'resource' => get_class($this->resource), 'service' => $this->serviceName, $this->responseKey => $data); if (LudoDB::isLoggingEnabled()) { $ret['log'] = array('time' => LudoDB::getElapsed(), 'queries' => LudoDB::getQueryCount()); } return json_encode($ret); }
/** * Add validation properties to LudoJS column * @param $children * @return mixed */ private function addValidation($children) { $validations = $this->resource->configParser()->getColumnsToValidate(); foreach ($validations as $col => $validation) { foreach ($validation as $key => $value) { switch ($key) { case "regex": $tokens = explode("/", $value); $flag = array_pop($tokens); if ($this->isRegexFlag($flag)) { $flag = str_replace("s", "g", $flag); } $tokens[] = $flag; $children[$col][$key] = implode("/", $tokens); break; default: $children[$col][$key] = $value; } } } return $children; }
/** * Execute commit on classes for external columns. * @param LudoDBObject $class */ private function commitExternal($class) { $class->commit(); }
/** * Clear all cached config parsers */ public static function clearParsers() { self::$configParsers = array(); }
/** * Return "update" SQL. * @return string */ public function getUpdateSql() { return "update " . $this->obj->configParser()->getTableName() . " set " . $this->getUpdatesForSql($this->obj->getUncommitted()) . " where " . $this->obj->configParser()->getIdField() . " = '" . $this->obj->getId() . "'"; }