public datasetType ( boolean $DatasetType = false ) | ||
$DatasetType | boolean |
public function datasetType($DatasetType = false)
{
if ($DatasetType !== false) {
// Make sure the type isn't changed if the result is already fetched.
if (!is_null($this->_Result) && $DatasetType != $this->_DatasetType) {
// Loop through the dataset and switch the types.
$Count = count($this->_Result);
foreach ($this->_Result as $Index => &$Row) {
switch ($DatasetType) {
case DATASET_TYPE_ARRAY:
$Row = (array) $Row;
//$this->_Result[$Index] = (array)$this->_Result[$Index];
break;
case DATASET_TYPE_OBJECT:
$Row = (object) $Row;
//$this->_Result[$Index] = (object)$this->_Result[$Index];
break;
}
}
}
$this->_DatasetType = $DatasetType;
return $this;
} else {
return $this->_DatasetType;
}
}
/** * Create some virtual properties. * * @param $Name * @return Gdn_DataSet */ public function __get($Name) { switch ($Name) { case 'CommentData': Deprecated('ActivityController->CommentData', "ActivityController->data('Activities')"); $Result = new Gdn_DataSet(array(), DATASET_TYPE_OBJECT); return $Result; case 'ActivityData': Deprecated('ActivityController->ActivityData', "ActivityController->data('Activities')"); $Result = new Gdn_DataSet($this->data('Activities'), DATASET_TYPE_ARRAY); $Result->datasetType(DATASET_TYPE_OBJECT); return $Result; } }