本文整理汇总了PHP中Gdn_Format::objectAsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::objectAsArray方法的具体用法?PHP Gdn_Format::objectAsArray怎么用?PHP Gdn_Format::objectAsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::objectAsArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanErrorArguments
/**
*
*
* @param $Var
* @param array $BlackList
*/
function cleanErrorArguments(&$Var, $BlackList = array('configuration', 'config', 'database', 'password'))
{
if (is_array($Var)) {
foreach ($Var as $Key => $Value) {
if (in_array(strtolower($Key), $BlackList)) {
$Var[$Key] = 'SECURITY';
} else {
if (is_object($Value)) {
$Value = Gdn_Format::objectAsArray($Value);
$Var[$Key] = $Value;
}
if (is_array($Value)) {
cleanErrorArguments($Var[$Key], $BlackList);
}
}
}
}
}
示例2: setData
/**
* Assign a set of data to be displayed in the form elements.
*
* @param array $Data A result resource or associative array containing data to be filled in
*/
public function setData($Data)
{
if (is_object($Data) === true) {
// If this is a result object (/garden/library/database/class.dataset.php)
// retrieve it's values as arrays
if ($Data instanceof DataSet) {
$ResultSet = $Data->resultArray();
if (count($ResultSet) > 0) {
$this->_DataArray = $ResultSet[0];
}
} else {
// Otherwise assume it is an object representation of a data row.
$this->_DataArray = Gdn_Format::objectAsArray($Data);
}
} elseif (is_array($Data)) {
$this->_DataArray = $Data;
}
}
示例3: set
/**
* Adds values to the $this->_Sets collection. Allows for the inserting
* and updating of values to the db.
*
* @param mixed $Field The name of the field to save value as. Alternately this can be an array
* of $FieldName => $Value pairs, or even an object of $DataSet->Field properties containing one rowset.
* @param string $Value The value to be set in $Field. Ignored if $Field was an array or object.
* @param boolean $EscapeString A boolean value indicating if the $Value(s) should be escaped or not.
* @param boolean $CreateNewNamedParameter A boolean value indicating that if (a) a named parameter is being
* created, and (b) that name already exists in $this->_NamedParameters
* collection, then a new one should be created rather than overwriting the
* existing one.
* @return Gdn_SQLDriver $this Returns this for fluent calls
* @throws \Exception Throws an exception if an invalid type is passed for {@link $Value}.
*/
public function set($Field, $Value = '', $EscapeString = true, $CreateNewNamedParameter = true)
{
$Field = Gdn_Format::objectAsArray($Field);
if (!is_array($Field)) {
$Field = array($Field => $Value);
}
foreach ($Field as $f => $v) {
if (is_array($v) || is_object($v)) {
throw new Exception('Invalid value type (' . gettype($v) . ') in INSERT/UPDATE statement.', 500);
} else {
if (in_array(substr($f, -1), ['+', '-'], true)) {
// This is an increment/decrement.
$op = substr($f, -1);
$f = substr($f, 0, -1);
$parameter = $this->namedParameter($f, $CreateNewNamedParameter);
$this->_NamedParameters[$parameter] = $v;
$this->_Sets[$this->escapeIdentifier($f)] = $this->escapeIdentifier($f) . " {$op} " . $parameter;
} elseif ($EscapeString) {
$NamedParameter = $this->namedParameter($f, $CreateNewNamedParameter);
$this->_NamedParameters[$NamedParameter] = $v;
$this->_Sets[$this->escapeIdentifier($f)] = $NamedParameter;
} else {
$this->_Sets[$this->escapeIdentifier($f)] = $v;
}
}
}
return $this;
}