本文整理汇总了PHP中array_to_object函数的典型用法代码示例。如果您正苦于以下问题:PHP array_to_object函数的具体用法?PHP array_to_object怎么用?PHP array_to_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_to_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->load->library(['pagination', 'table']);
$page = !empty($this->uri->segment(4)) ? $this->_perpage * ($this->uri->segment(4) - 1) : 0;
$config['base_url'] = base_url($this->base . '/index/');
$config['total_rows'] = $this->{$this->router->fetch_class()}->count_all();
$this->_set_datagrid_header(isset($this->data['recursive']) ? $this->data['recursive'][1] : NULL);
$unshift = [$this->primary_key => 'Primary Key'] + $this->data['datagrid_header'] + ['role' => 'Role'];
$items = $this->_get_items();
$this->user->order_by($this->primary_key, 'ASC');
$this->user->limit($this->_perpage, $page);
foreach ($this->user->with('user_role')->get_all() as $index => $row) {
$row = object_to_array($row);
foreach ($row as $k => $v) {
if (!empty($items) && array_key_exists($k, $items)) {
$row[$k] = empty($v) ? $v : $items[$k][$v];
}
}
$row['role'] = '';
foreach ($row['user_role'] as $key => $value) {
$role = $this->role->get($value['role_id']);
$row['role'] .= '<span class="label label-info">' . $role->role_name . '</span> ';
}
$row = array_intersect_key($row, $unshift);
$this->data['datagrid'][$index] = array_to_object($row);
}
$this->pagination->initialize($config);
$this->data['links'] = $this->pagination->create_links();
}
示例2: getAwards
public static function getAwards()
{
$awards = Config::get('awards.types');
foreach ($awards as &$award) {
$award = array_to_object($award);
}
return $awards;
}
示例3: array_to_object
/**
* Converting an array into object
*
* @param array $array Source
* @return object
*/
function array_to_object(array $array)
{
$obj = new stdClass();
foreach ($array as $key => $val) {
$obj->{$key} = is_array($val) ? array_to_object($val) : $val;
}
return $obj;
}
示例4: test_array_to_object
public function test_array_to_object()
{
$a = ['key1' => 'val1', 'key2' => 'val2'];
$o = $this->_get_test_obj();
$this->assertEquals($o, array_to_object($a));
$this->assertNotEquals($a, $o);
$o->key3 = 'val3';
$this->assertNotEquals($a + ['key3' => 'val3'], array_to_object($o));
}
示例5: loadPluginConfi
protected function loadPluginConfi($object = true)
{
$plugin_configuration = array('roles' => get_option('cdm_roles'), 'batch_access' => get_option('cdm_batch_access'), 'client_comment' => get_option('cdm_client_comment'), 'client_upload' => get_option('cdm_client_upload'), 'display_month' => get_option('cdm_display_month'), 'display_year' => get_option('cdm_display_year'), 'display_date' => get_option('cdm_display_date'), 'display_all' => get_option('cdm_display_all'), 'external_css' => get_option('cdm_external_css'), 'secure_files' => get_option('cdm_secure_files'), 'allowed_extension' => get_option('cdm_allowed_extension'), 'update_options' => get_option('cdm_update_options'), 'filesize' => get_option('cdm_allowed_filesize'), 'userrole' => get_option('cdm_userroles'));
if ($object) {
return array_to_object($plugin_configuration);
} else {
return $plugin_configuration;
}
}
示例6: getByID
public static function getByID($fsfID)
{
$db = Loader::db();
$r = $db->GetRow('SELECT * FROM FileSetFiles WHERE fsfID = ?', array($fsfID));
if (is_array($r) && $r['fsfID']) {
$fsf = new static();
$fsf = array_to_object($fsf, $r);
return $fsf;
}
}
示例7: testArrayToObject
public function testArrayToObject()
{
$obj1 = new stdClass();
$obj1->foo = 'bar';
$obj2 = new stdClass();
$obj2->foo = $obj1;
$this->assertEquals(new stdClass(), array_to_object([]));
$this->assertEquals($obj1, array_to_object(['foo' => 'bar']));
$this->assertEquals($obj2, array_to_object(['foo' => ['foo' => 'bar']]));
}
示例8: getByID
public static function getByID($logID)
{
$db = Database::get();
$r = $db->Execute("select * from Logs where logID = ?", array($logID));
if ($r) {
$row = $r->FetchRow();
$obj = new static();
$obj = array_to_object($obj, $row);
return $obj;
}
}
示例9: get_templates
private function get_templates()
{
$this->load->model('template_model');
$ids = $this->config->item('index_template_ids');
$params = buildQueryOperation(array(), $this->common->get_start_row(), $this->common->get_page_size());
foreach ((array) $ids as $id) {
$params->QueryOperator->Filter[] = array_to_object(array('Name' => 'ID', 'Value' => $id));
}
$result = wrapWcfResult($this->template_model->get_templates_list($params, 'object'), 'Template');
return empty($result->Data['rows']) ? [] : object_to_array($result->Data['rows']);
}
示例10: array_to_object
function array_to_object($array)
{
$object = new stdClass();
foreach ($array as $key => $value) {
if (is_array($value)) {
$object->{$key} = array_to_object($value);
} else {
$object->{$key} = $value;
}
}
return $object;
}
示例11: array_to_object
function array_to_object($array)
{
$obj = new stdClass();
foreach ($array as $k => $v) {
if (is_array($v)) {
$obj->{$k} = array_to_object($v);
} else {
$obj->{$k} = $v;
}
}
return $obj;
}
示例12: Find
public function Find($where, $args = array())
{
$db = Loader::db();
$return = array();
$r = $db->GetAll('select * from ' . $this->_table . ' where ' . $where, $args);
foreach ($r as $row) {
$o = new $this();
$o = array_to_object($o, $row);
$return[] = $o;
}
return $return;
}
示例13: Find
public function Find($where)
{
$db = Loader::db();
$r = $db->Execute('select * from UserBannedIPs where ' . $where);
$ips = array();
while ($row = $r->FetchRow()) {
$ip = new self();
$ip = array_to_object(new self(), $row);
$ips[] = $ip;
}
return $ips;
}
示例14: get_verify_code_by_code
/**
* 根据激活码和应用获取记录
*
* @param string $code 激活码
* @param string $application 应用
* @return array 返回数组
*/
public function get_verify_code_by_code($code, $application)
{
try {
$this->load->helper('query_builder');
$params = buildQueryOperation(array(), 1, 1);
$params->QueryOperator->Filter = array(array_to_object(array('Name' => 'Code', 'Value' => $code)), array_to_object(array('Name' => 'Application', 'Value' => $application)));
$result = wrapWcfResult($this->get_verify_codes($params), 'VerifyCode');
return empty($result->Data['rows'][0]) ? [] : $result->Data['rows'][0];
} catch (Exception $ex) {
return [];
}
}
示例15: get
private function get($where, $var)
{
$q = "select * from Users {$where}";
$r = $this->connection->query($q, array($var));
if ($r && $r->numRows() > 0) {
$row = $r->fetchRow();
$r->free();
$ui = $this->application->make('Concrete\\Core\\User\\UserInfo');
$ui = array_to_object($ui, $row);
return $ui;
}
}