当前位置: 首页>>代码示例>>PHP>>正文


PHP Arr::assoc_to_keyval方法代码示例

本文整理汇总了PHP中Arr::assoc_to_keyval方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::assoc_to_keyval方法的具体用法?PHP Arr::assoc_to_keyval怎么用?PHP Arr::assoc_to_keyval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arr的用法示例。


在下文中一共展示了Arr::assoc_to_keyval方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_edit

 public function action_edit($id = null)
 {
     $post = Model_Post::find($id);
     $val = Model_Post::validate('edit');
     if ($val->run()) {
         $post->title = Input::post('title');
         //$post->slug = Input::post('slug');
         $post->summary = Input::post('summary');
         $post->body = Input::post('body');
         $post->user_id = Input::post('user_id');
         if ($post->save()) {
             Session::set_flash('success', 'Updated post #' . $id);
             Response::redirect('admin/posts');
         } else {
             Session::set_flash('error', 'Could not update post #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $post->title = $val->validated('title');
             $post->slug = $val->validated('slug');
             $post->summary = $val->validated('summary');
             $post->body = $val->validated('body');
             $post->user_id = $val->validated('user_id');
             Session::set_flash('error', $val->show_errors());
         }
         $this->template->set_global('post', $post, false);
     }
     $this->template->title = "Create Post";
     $view = View::forge('admin/posts/create');
     // Set some data
     $view->set_global('users', Arr::assoc_to_keyval(Model_User::find('all'), 'id', 'username'));
     $this->template->content = $view;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:33,代码来源:posts.php

示例2: test_assoc_to_keyval

 /**
  * Tests Arr::assoc_to_keyval()
  *
  * @test
  */
 public function test_assoc_to_keyval()
 {
     $assoc = array(array('color' => 'red', 'rank' => 4, 'name' => 'Apple'), array('color' => 'yellow', 'rank' => 3, 'name' => 'Banana'), array('color' => 'purple', 'rank' => 2, 'name' => 'Grape'));
     $expected = array('red' => 'Apple', 'yellow' => 'Banana', 'purple' => 'Grape');
     $output = Arr::assoc_to_keyval($assoc, 'color', 'name');
     $this->assertEquals($expected, $output);
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:12,代码来源:arr.php

示例3: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Data_Supplier_List');
     $data_supplier_list = Model_Data_Supplier_List::find($id);
     $val = Model_Data_Supplier_List::validate('edit');
     if ($val->run()) {
         $data_supplier_list->data_supplier_id = Input::post('data_supplier_id');
         $data_supplier_list->title = Input::post('title');
         $data_supplier_list->datafile = Input::post('datafile');
         $data_supplier_list->cost = Input::post('cost');
         $data_supplier_list->total_leads = Input::post('total_leads');
         if ($data_supplier_list->save()) {
             Session::set_flash('success', 'Updated data_supplier_list #' . $id);
             Response::redirect('data/supplier/list');
         } else {
             Session::set_flash('error', 'Could not update data_supplier_list #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $data_supplier_list->data_supplier_id = $val->validated('data_supplier_id');
             $data_supplier_list->title = $val->validated('title');
             $data_supplier_list->datafile = $val->validated('datafile');
             $data_supplier_list->cost = $val->validated('cost');
             $data_supplier_list->total_leads = $val->validated('total_leads');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('data_supplier_list', $data_supplier_list, false);
     }
     $this->template->set_global('data_suppliers', Arr::assoc_to_keyval(Model_Data_supplier::find('all'), 'id', 'company_name'), false);
     $this->template->title = "Data_supplier_lists";
     $this->template->content = View::forge('data/supplier/list/edit');
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:32,代码来源:list.php

示例4: getSubjectOptions

 /**
  * Gets all subjects as options used for forms
  *
  * @return array the subjects as assoc array ['id' => 'value']
  */
 public static function getSubjectOptions()
 {
     $where = [];
     if (!Model_User::is_current_user('admin')) {
         $where = ['user_id' => Auth::get('id')];
     }
     $subjects = static::find('all', ['where' => $where]);
     return Arr::assoc_to_keyval($subjects, 'id', 'subject_code');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:14,代码来源:subject.php

示例5: items

 public static function items($type, $add_empty = true)
 {
     $ret = Arr::assoc_to_keyval(self::find('all', array('where' => array(array('type', $type)))), 'code', 'name');
     if ($add_empty) {
         $items[0] = '';
         $ret = array_merge($items, $ret);
     }
     return $ret;
 }
开发者ID:nobuhiko,项目名称:mylogbook,代码行数:9,代码来源:lookup.php

示例6: to_array

 /**
  * Allow converting this object to an array
  *
  * @param bool $custom
  * @param bool $recurse
  * @param bool $eav
  *
  * @internal param \Orm\whether $bool or not to include the custom data array
  *
  * @return  array
  */
 public function to_array($custom = false, $recurse = false, $eav = false)
 {
     // storage for the result
     $array = array();
     // reset the references array on first call
     $recurse or static::$to_array_references = array(get_class($this));
     // make sure all data is scalar or array
     if ($custom) {
         foreach ($this->_custom_data as $key => $val) {
             if (is_object($val)) {
                 if (method_exists($val, '__toString')) {
                     $val = (string) $val;
                 } else {
                     $val = get_object_vars($val);
                 }
             }
             $array[$key] = $val;
         }
     }
     // make sure all data is scalar or array
     foreach ($this->_data as $key => $val) {
         if (is_object($val)) {
             if (method_exists($val, '__toString')) {
                 $val = (string) $val;
             } else {
                 $val = get_object_vars($val);
             }
         }
         $array[$key] = $val;
     }
     // convert relations
     foreach ($this->_data_relations as $name => $rel) {
         if (is_array($rel)) {
             $array[$name] = array();
             if (!empty($rel)) {
                 static::$to_array_references[] = get_class(reset($rel));
                 foreach ($rel as $id => $r) {
                     $array[$name][$id] = $r->to_array($custom, true, $eav);
                 }
             }
         } else {
             if (!in_array(get_class($rel), static::$to_array_references)) {
                 if (is_null($rel)) {
                     $array[$name] = null;
                 } else {
                     static::$to_array_references[] = get_class($rel);
                     $array[$name] = $rel->to_array($custom, true, $eav);
                 }
             }
         }
     }
     // get eav relations
     if ($eav and property_exists(get_called_class(), '_eav')) {
         // loop through the defined EAV containers
         foreach (static::$_eav as $rel => $settings) {
             // normalize the container definition, could be string or array
             if (is_string($settings)) {
                 $rel = $settings;
                 $settings = array();
             }
             // determine attribute and value column names
             $attr = \Arr::get($settings, 'attribute', 'attribute');
             $val = \Arr::get($settings, 'value', 'value');
             // check if relation is present
             if (array_key_exists($rel, $array)) {
                 // get eav properties
                 $container = \Arr::assoc_to_keyval($array[$rel], $attr, $val);
                 // merge eav properties to array without overwritting anything
                 $array = array_merge($container, $array);
                 // we don't need this relation anymore
                 unset($array[$rel]);
             }
         }
     }
     // strip any excluded values from the array
     foreach (static::$_to_array_exclude as $key) {
         if (array_key_exists($key, $array)) {
             unset($array[$key]);
         }
     }
     return $array;
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:93,代码来源:model.php

示例7: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Dialler_Campaign');
     $dialler_campaign = Model_Dialler_Campaign::find($id);
     $val = Model_Dialler_Campaign::validate('edit');
     if ($val->run()) {
         $dialler_campaign->campaign_title = Input::post('campaign_title');
         $dialler_campaign->campaign_name = Input::post('campaign_name');
         $dialler_campaign->campaign_description = Input::post('campaign_description');
         $dialler_campaign->call_center_id = Input::post('call_center_id');
         if ($dialler_campaign->save()) {
             Session::set_flash('success', 'Updated dialler_campaign #' . $id);
             Response::redirect('dialler/campaign');
         } else {
             Session::set_flash('error', 'Could not update dialler_campaign #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $dialler_campaign->campaign_title = $val->validated('campaign_title');
             $dialler_campaign->campaign_name = $val->validated('campaign_name');
             $dialler_campaign->campaign_description = $val->validated('campaign_description');
             $dialler_campaign->call_center_id = $val->validated('call_center_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('dialler_campaign', $dialler_campaign, false);
     }
     $this->template->set_global('call_centers', Arr::assoc_to_keyval(Model_Call_Center::find('all'), 'id', 'title'), false);
     $this->template->title = "Dialler_campaigns";
     $this->template->content = View::forge('dialler/campaign/edit');
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:30,代码来源:campaign.php

示例8: array

<?php

$options = \Arr::assoc_to_keyval(\Novius\Partners\Model_Partner::find('all'), 'part_id', 'part_title');
return array('fieldset_fields' => array('group_id' => array('label' => '', 'form' => array('type' => 'hidden')), 'group_order' => array('label' => '', 'form' => array('type' => 'hidden')), 'group_title' => array('label' => __('Group title')), 'partners' => array('label' => __('Partners'), 'renderer' => 'Novius\\Renderers\\Renderer_Multiselect', 'renderer_options' => array('sortable' => true), 'form' => array('options' => $options), 'populate' => function ($item) {
    return array_keys($item->partners);
})));
开发者ID:novius,项目名称:novius_partners,代码行数:6,代码来源:group.config.php

示例9: findList

 protected static function findList($condition = null)
 {
     if (!is_array($condition) || \Arr::get($condition, 'select') === null) {
         $columns = static::getAttributes();
         $fields = array_splice($columns, 0, 2);
     } else {
         if (\Arr::get($condition, 'select') !== null) {
             $fields = count($condition['select']) == 2 ? $condition['select'] : array_splice($condition['select'], 0, 2);
         }
     }
     $condition = $condition ?: array();
     $rs = static::find('all', array_merge($condition, array('select' => $fields)));
     //$key = array_shift($fields);
     $key = current($fields);
     //$value = array_pop($fields);
     $value = next($fields);
     return \Arr::assoc_to_keyval($rs, $key, $value);
 }
开发者ID:khoapossible,项目名称:vision_system,代码行数:18,代码来源:advanced.php

示例10: get_list_of_teachers

 /**
  * Get list of teachers
  *
  * @return array 
  */
 public static function get_list_of_teachers()
 {
     $users = [];
     if (!Model_User::is_current_user('teacher')) {
         $users = Model_User::find('all', array('where' => array('group' => '50')));
     } else {
     }
     return Arr::assoc_to_keyval($users, 'id', 'fullname');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:14,代码来源:user.php

示例11: getTypeOptions

 public static function getTypeOptions()
 {
     $types = static::find('all');
     return Arr::assoc_to_keyval($types, 'id', 'type_name');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:5,代码来源:type.php

示例12: getCoursesOptions

 public static function getCoursesOptions()
 {
     $courses = static::find('all');
     return Arr::assoc_to_keyval($courses, 'id', 'course_name');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:5,代码来源:course.php

示例13: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Database_Query');
     $database_query = Model_Database_Query::find($id);
     $val = Model_Database_Query::validate('edit');
     if ($val->run()) {
         $database_query->title = Input::post('title');
         $database_query->description = Input::post('description');
         $database_query->query = Input::post('query');
         $database_query->cache_time = Input::post('cache_time');
         $database_query->database_server_id = Input::post('database_server_id');
         $database_query->database = Input::post('database');
         $database_query->username = Input::post('username');
         $database_query->password = Input::post('password');
         if ($database_query->save()) {
             Session::set_flash('success', 'Updated database_query #' . $id);
             Response::redirect('database/query');
         } else {
             Session::set_flash('error', 'Could not update database_query #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $database_query->title = $val->validated('title');
             $database_query->description = $val->validated('description');
             $database_query->query = $val->validated('query');
             $database_query->cache_time = $val->validated('cache_time');
             $database_query->database_server_id = $val->validated('database_server_id');
             $database_query->database = $val->validated('database');
             $database_query->username = $val->validated('username');
             $database_query->password = $val->validated('password');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('database_query', $database_query, false);
     }
     $this->template->set_global('server_id', null, false);
     $this->template->set_global('database_servers', Arr::assoc_to_keyval(Model_Database_Server::find('all'), 'id', 'title'), false);
     $this->template->title = "Database_queries";
     $this->template->content = View::forge('database/query/edit');
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:39,代码来源:query.php


注:本文中的Arr::assoc_to_keyval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。