本文整理匯總了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);
}
示例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);
}
}
示例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'));
}
示例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');
}
示例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);
}