當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::foreign_key方法代碼示例

本文整理匯總了PHP中Inflector::foreign_key方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::foreign_key方法的具體用法?PHP Inflector::foreign_key怎麽用?PHP Inflector::foreign_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inflector的用法示例。


在下文中一共展示了Inflector::foreign_key方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct($from, $name, array $config)
 {
     $this->name = $name;
     $this->model_from = $from;
     $this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
     $this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from;
     $this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to;
     $this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array();
     if (!empty($config['table_through'])) {
         $this->table_through = $config['table_through'];
     } else {
         $table_name = array($this->model_from, $this->model_to);
         natcasesort($table_name);
         $table_name = array_merge($table_name);
         $this->table_through = \Inflector::tableize($table_name[0]) . '_' . \Inflector::tableize($table_name[1]);
     }
     $this->key_through_from = !empty($config['key_through_from']) ? (array) $config['key_through_from'] : (array) \Inflector::foreign_key($this->model_from);
     $this->key_through_to = !empty($config['key_through_to']) ? (array) $config['key_through_to'] : (array) \Inflector::foreign_key($this->model_to);
     $this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
     $this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete;
     if (!class_exists($this->model_to)) {
         throw new \FuelException('Related model not found by Many_Many relation "' . $this->name . '": ' . $this->model_to);
     }
     $this->model_to = get_real_class($this->model_to);
 }
開發者ID:rickmellor,項目名稱:Infrastructure,代碼行數:25,代碼來源:manymany.php

示例2: __construct

 public function __construct($from, $name, array $config)
 {
     $this->name = $name;
     $this->model_from = $from;
     $this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
     $this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from;
     $this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : (array) \Inflector::foreign_key($this->model_from);
     $this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
     $this->cascade_delete = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_delete;
     if (!class_exists($this->model_to)) {
         throw new Exception('Related model not found by Has_Many relation "' . $this->name . '": ' . $this->model_to);
     }
 }
開發者ID:bryanheo,項目名稱:FuelPHP-Auth-AJAX,代碼行數:13,代碼來源:hasmany.php

示例3: test_foreign_key_with_model_prefx

 /**
  * Test for Inflector::foreign_key()
  *
  * @test
  */
 public function test_foreign_key_with_model_prefx()
 {
     $this->assertEquals('inflector_id', Inflector::foreign_key('Model_Inflector'));
 }
開發者ID:phabos,項目名稱:fuel-core,代碼行數:9,代碼來源:inflector.php

示例4: testForeign_key

 /**
  *  Test {@link Inflector::foreign_key()}
  */
 public function testForeign_key()
 {
     $this->assertEquals(Inflector::foreign_key('people'), 'people_id');
     $this->assertEquals(Inflector::foreign_key('queries'), 'queries_id');
 }
開發者ID:phpontrax,項目名稱:trax,代碼行數:8,代碼來源:InflectorTest.php

示例5: test_foreign_key

 /**
  * Test for Inflector::foreign_key()
  *
  * @test
  */
 public function test_foreign_key()
 {
     $output = Inflector::foreign_key('Inflector');
     $expected = 'inflector_id';
     $this->assertEquals($expected, $output);
     $output = Inflector::foreign_key('Inflector', false);
     $expected = 'inflectorid';
     $this->assertEquals($expected, $output);
 }
開發者ID:bryanheo,項目名稱:FuelPHP-Auth-AJAX,代碼行數:14,代碼來源:inflector.php


注:本文中的Inflector::foreign_key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。