本文整理汇总了PHP中Jam::meta方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::meta方法的具体用法?PHP Jam::meta怎么用?PHP Jam::meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::meta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_constructor
public function test_constructor()
{
$select = Jam_Query_Builder_Select::factory('test_author');
$this->assertInstanceOf('Jam_Query_Builder_Select', $select);
$this->assertEquals(Jam::meta('test_author'), $select->meta());
$this->assertEquals('SELECT `test_authors`.* FROM `test_authors`', (string) $select);
}
示例2: meta
/**
* Getter of the meta object for this iterator (based on $_model)
* @return Jam_Model
* @throws Kohana_Exception If $_model not present
*/
public function meta()
{
if (!$this->model()) {
throw new Kohana_Exception('Model not set');
}
return Jam::meta($this->model());
}
示例3: compile
public function compile($db = NULL)
{
if ($this->context_model() and $meta = Jam::meta(Jam_Query_Builder::aliased_model($this->context_model()))) {
$db = Database::instance($meta->db());
}
$original_on = $this->_on;
$original_using = $this->_using;
$original_table = $this->_table;
if (!empty($this->_on)) {
foreach ($this->_on as &$condition) {
$condition[0] = Jam_Query_Builder::resolve_attribute_name($condition[0], $this->model() ? $this->model() : $this->_table);
$condition[2] = Jam_Query_Builder::resolve_attribute_name($condition[2], $this->context_model());
}
}
$this->_table = Jam_Query_Builder::resolve_table_alias($this->_table);
if (!empty($this->_using)) {
foreach ($this->_using as &$column) {
$column = Jam_Query_Builder::resolve_attribute_name($column, $this->meta());
}
}
$additional_joins = '';
foreach ($this->_joins as $join) {
$additional_joins .= ' ' . $join->compile($db);
}
$compiled = parent::compile($db) . $additional_joins;
$this->_on = $original_on;
$this->_using = $original_using;
$this->_table = $original_table;
return $compiled;
}
示例4: test_initialize
/**
* @covers Model_Purchase_Item_Promotion::initialize
*/
public function test_initialize()
{
$meta = Jam::meta('purchase_item_promotion');
$this->assertSame('purchase_items', $meta->table());
$this->assertTrue($meta->field('is_payable')->default);
$this->assertTrue($meta->field('is_discount')->default);
}
示例5: test_constructor
public function test_constructor()
{
$select = Jam_Query_Builder_Update::factory('test_author');
$select->value('name', 'Test');
$this->assertInstanceOf('Jam_Query_Builder_Update', $select);
$this->assertEquals(Jam::meta('test_author'), $select->meta());
$this->assertEquals('UPDATE `test_authors` SET `name` = \'Test\'', (string) $select);
}
示例6: test_initialize
public function test_initialize()
{
$association = Jam::meta('purchase_item_product')->association('shipping_item');
$this->assertInstanceOf('Jam_Association_Hasone', $association);
$this->assertAttributeSame('purchase_item_id', 'foreign_key', $association);
$this->assertAttributeSame('purchase_item', 'inverse_of', $association);
$this->assertAttributeSame(Jam_Association::DELETE, 'dependent', $association);
}
示例7: __construct
/**
* Constructs a new Jam_Builder instance.
*
* $model is not actually allowed to be NULL. It has
* a default because PHP throws strict errors otherwise.
*
* @throws Kohana_Exception
* @param string|null $model
* @param mixed|null $key
*/
public function __construct($model)
{
parent::__construct();
$this->_meta = Jam::meta($model);
if (!$this->_meta) {
throw new Kohana_Exception('There is no model :model for select', array(':model' => $model));
}
$this->meta()->events()->trigger('builder.after_construct', $this);
}
示例8: __construct
/**
* Constructs a new Jam_Builder instance.
*
* $model is not actually allowed to be NULL. It has
* a default because PHP throws strict errors otherwise.
*
* @throws Kohana_Exception
* @param string|null $model
* @param mixed|null $key
*/
public function __construct($model, $key = NULL)
{
parent::__construct();
$this->_meta = Jam::meta($model);
if ($key !== NULL) {
Jam_Query_Builder::find_primary_key($this, $key);
}
$this->meta()->events()->trigger('builder.after_construct', $this);
}
示例9: test_initialize
/**
* @covers ::initialize
*/
public function test_initialize()
{
$category = Jam::meta('category2');
$this->assertArrayHasKey('parent', $category->associations());
$this->assertInstanceOf('Jam_Association_Materializedpath_Belongsto', $category->association('parent'));
$this->assertArrayHasKey('children', $category->associations());
$this->assertInstanceOf('Jam_Association_Materializedpath_Hasmany', $category->association('children'));
$this->assertArrayHasKey('path', $category->fields());
}
示例10: setUp
public function setUp()
{
parent::setUp();
$this->collection = new Jam_Query_Builder_Collection('test_element');
$this->collection->load_fields($this->data);
$this->parent = Jam::build('test_author')->load_fields(array('id' => 1, 'name' => 'author'));
$this->association = $this->getMock('Jam_Association_Hasmany', array('item_get', 'item_set', 'item_unset', 'clear', 'save', 'collection'));
$this->association->initialize(Jam::meta('test_author'), 'test_elements');
$this->array = new Jam_Array_Association();
$this->array->model('test_element')->association($this->association)->parent($this->parent);
}
示例11: action_index
public function action_index()
{
$q = $this->request->query('query');
$models = explode(',', $this->request->query('model'));
$response = array();
foreach ($models as $model) {
$name_key = $this->request->query('name') ?: Jam::meta($model)->name_key();
$model_response = Jam::all($model)->limit(5)->where_open()->where($name_key, 'LIKE', "%{$q}%")->or_where(':primary_key', '=', $q)->where_close();
$model_response = array_map(function ($item) use($models, $model) {
return array('name' => (count($models) > 1 ? ucfirst(Inflector::humanize($model)) . ' - ' : '') . '<span class="typeahead-display-val">' . $item->name() . '</span> <small class="muted">(' . $item->id() . ')</small>', 'id' => $item->id(), 'model' => $model);
}, $model_response->as_array());
$response = array_merge($response, $model_response);
}
$this->response->headers('Content-Type', 'application/json');
$this->response->body(json_encode($response));
}
示例12: test_initialize_skippable
public function test_initialize_skippable()
{
$meta = Jam::meta('test_purchase_item');
$this->assertInstanceOf('Jam_Field_Boolean', $meta->field(Jam_Behavior_Freezable::DEFAULT_SKIPPABLE_FIELD));
$behaviors = $meta->behaviors();
$freezable = $behaviors['freezable'];
$this->assertSame(Jam_Behavior_Freezable::DEFAULT_SKIPPABLE_FIELD, $freezable->_skippable);
$this->assertSame(array(), $freezable->_skippable_field_options);
$meta = Jam::meta('test_skippable');
$this->assertInstanceOf('Jam_Field_Boolean', $meta->field('is_meldable'));
$this->assertTrue($meta->field('is_meldable')->default);
$behaviors = $meta->behaviors();
$freezable = $behaviors['freezable'];
$this->assertSame('is_meldable', $freezable->_skippable);
$this->assertSame(array('default' => TRUE), $freezable->_skippable_field_options);
}
示例13: primary_key
/**
* Get the primary key from whatever value you have
*
* @param string $model_name The name of the model
* @param string|integer|Jam_Validated|array $value the value or a container of the value
* @return string|integer|NULL NULL when no value is provided or could be extracted.
*/
public static function primary_key($model_name, $value)
{
if (!$value) {
return NULL;
}
if ($value instanceof Jam_Validated) {
return $value->id();
}
if (is_integer($value) or is_numeric($value)) {
return (int) $value;
}
if (is_string($value)) {
return $value;
}
if (is_array($value)) {
return Arr::get($value, Jam::meta($model_name)->primary_key());
}
}
示例14: _get_current_children_of_parent
protected static function _get_current_children_of_parent($current, $parent, array $children = array())
{
if ($current === $parent) {
return $children;
}
foreach ($children as $association_name => $association_children) {
$name = is_numeric($association_name) ? $association_children : $association_name;
$association = Jam::meta($parent)->association($name);
if ($association and !$association->is_polymorphic()) {
$child_model = $association->foreign_model;
$child_children = is_numeric($association_name) ? array() : $association_children;
$result = Jam_Behavior_Cascade::_get_current_children_of_parent($current, $child_model, $child_children);
if ($result !== NULL) {
return $result;
}
}
}
return NULL;
}
示例15: model_after_delete
public function model_after_delete(Jam_Model $model)
{
if ($model->loaded() and $this->join_table_dependent) {
$this->erase_query($model)->execute(Jam::meta($this->model)->db());
}
}