コード例 #1
0
ファイル: Log.php プロジェクト: reekoheek/php-fw
	function log($priority, $message, $file = null, $line = null, $e = null) {
		$schema = "DEFAULT";
		$table = "logs";
		$trace = "";
		if (!empty($e)) {
			$trace = $e->getTraceAsString();
		}
		if (is_object($message)) {
			$message = JSON::encode($message);
		}
		$now = new Date();
		$log = array();
		$log["priority"] = $priority;
		$log["message"] = $message;
		$log["trace"] = $trace;
		$log["file"] = $file;
		$log["line"] = $line;
		$log["createdBy"] = "SYS";
		$log["createdTime"] = $now;
		$log["updatedBy"] = "SYS";
		$log["updatedTime"] = $now;

		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$insert = new Insert($table, $log, $schema);
		$link = DB::connect();
		$success = mysql_query($insert->sql(), $link);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot persist object. ".$result);
		}
	}
コード例 #2
0
ファイル: Validation.php プロジェクト: reekoheek/php-fw
	function validate(&$action) {
		Apu::dispatch($action->validation);
		if (!empty($GLOBALS["VALIDATION"])) {
			reset($GLOBALS["VALIDATION"]);
			while (list($method, $methodValidations) = each($GLOBALS["VALIDATION"])) {
				if ($method == "-" || $method == $action->method) {
					reset($methodValidations);
					while (list($field, $fieldValidations) = each($methodValidations)) {
						$fieldValue = $action->get($field);
						while (list($i, $val) = each($fieldValidations)) {
							$function = $val["validate"];
							$not = false;
							if (substr($val["validate"], 0, 1) == "!") {
								$function = trim($function, "!");
								$not = true;
							}
							$validate = Bean::invoke("Validation", $function, array(&$action, $val, $field, $not));
							if ($not) {
								$validate = !$validate;
							}
							if (!$validate) {
								$defaultMessage = $GLOBALS["CFG_VALIDATION"]->MSG[$val["validate"]];
								$action->addMsgMessage($defaultMessage, $field);
							}
						}
					}
				}
			}
		}
	}
コード例 #3
0
ファイル: RpcAction.php プロジェクト: reekoheek/php-fw
	function doInvoke() {
		try {
		$result = Bean::invoke($this->md, $this->mt, $this->ps);
		$this->json = $result;
		} catch (Exception $e) {
			$error = new stdClass();
			$error->error = $e->getMessage();
			$this->json = $error;
		}
	}
コード例 #4
0
ファイル: DB.php プロジェクト: reekoheek/php-fw
	function delete($table, $obj, $schema = "DEFAULT") {
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$objId = Bean::get($obj, "__ID__");
		if (empty($objId)) {
			throw new Exception("Cannot delete unpersisted object");
		}
		$delete = new Delete($table, $obj, $schema);
		$success = DB::query($delete, $schema);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot delete object. ".$result);
		}
	}
コード例 #5
0
ファイル: Query.php プロジェクト: reekoheek/php-fw
	function escape($value, $name) {
		$schema = $this->schema;
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$value = Bean::invoke(String::camelize('_'.$driver.'_driver'), "escape", array($value, $name, $this->meta));
		return $value;
	}
コード例 #6
0
ファイル: BaseAction.php プロジェクト: reekoheek/php-fw
	function listen() {
		$this->pre();
		$methodName = String::camelize("do_".$this->method);
		Bean::invoke($this, $methodName);
		$this->post();
	}