• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Jam类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initialize

 public static function initialize(Jam_Meta $meta)
 {
     $meta->db(Kohana::TESTING);
     parent::initialize($meta);
     $meta->behaviors(['username' => Jam::behavior('username')]);
     $meta->associations(array('user_tokens' => Jam::association('hasmany', array('foreign_model' => 'test_user_token', 'foreign_key' => 'test_user_id')), 'roles' => Jam::association('manytomany', array('foreign_model' => 'test_role', 'join_table' => 'test_roles_users', 'foreign_key' => 'test_role_id', 'association_foreign_key' => 'test_user_id'))));
 }
开发者ID:openbuildings,项目名称:jam-auth,代码行数:7,代码来源:User.php


示例2: initialize

 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('upload', array('server' => 'test_local')), 'file2' => Jam::field('upload', array('server' => 'test_local', 'path' => 'test/:model/:model:id'))));
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Upload.php


示例3: test_empty_value

 public function test_empty_value()
 {
     $model = Jam::build('test_position');
     $field = new Jam_Field_Timestamp(array('timezone' => new Jam_Timezone()));
     $value = $field->set($model, '', FALSE);
     $this->assertNull($value);
 }
开发者ID:openbuildings,项目名称:jam,代码行数:7,代码来源:TimestampTest.php


示例4: duplicate

 public function duplicate()
 {
     $duplicate = Jam::build('brand_purchase_shipping', array('brand_purchase' => $this->brand_purchase));
     // This is needed to counteract inverse_of brand_purchase in brand_purchase_shipping
     $this->brand_purchase->shipping = $this;
     return $duplicate;
 }
开发者ID:openbuildings,项目名称:shipping,代码行数:7,代码来源:Shipping.php


示例5: test_not_expired

 /**
  * @covers Model_Collection_Promotion::not_expired
  */
 public function test_not_expired()
 {
     $time = strtotime('2013-02-02');
     $sql = (string) Jam::all('promotion')->not_expired($time);
     $expected_sql = "SELECT `promotions`.* FROM `promotions` WHERE (`promotions`.`expires_at` IS NULL OR `promotions`.`expires_at` >= '2013-02-02 00:00:00')";
     $this->assertEquals($expected_sql, $sql);
 }
开发者ID:openbuildings,项目名称:promotions,代码行数:10,代码来源:PromotionTest.php


示例6: test_change_password

 /**
  * @dataProvider data_change_password
  */
 public function test_change_password($password, $expected_hashed)
 {
     $field = new Jam_Field_Password();
     $model = Jam::build('test_position');
     $hashed = $field->convert($model, $password, FALSE);
     $this->assertEquals($expected_hashed, $hashed);
 }
开发者ID:openbuildings,项目名称:jam,代码行数:10,代码来源:PasswordTest.php


示例7: 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;
 }
开发者ID:Konro1,项目名称:pms,代码行数:30,代码来源:Join.php


示例8: initialize

 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'model' => Jam::field('polymorphic')));
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Position.php


示例9: initialize

 public static function initialize(Jam_Meta $meta)
 {
     $meta->table('vocabularies')->name_key('name');
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array())));
     $meta->associations(array('terms' => Jam::association('hasmany', array('inverse_of' => 'vocabulary'))));
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s', 'label' => "Last edited"))));
 }
开发者ID:openbuildings,项目名称:jam-taxonomy,代码行数:7,代码来源:Vocabulary.php


示例10: get_user

 public function get_user()
 {
     if ($this->enabled() and $this->logged_in()) {
         $user = Jam::find_or_build($this->_user_model, array($this->_service_field => $this->service_uid()));
         $user->_is_new = TRUE;
         $data = $this->service_user_info();
         if (!$user->loaded()) {
             if (isset($data['email'])) {
                 $user = Jam::find_or_build($this->_user_model, array('email' => $data['email']));
                 if ($user->loaded()) {
                     $user->_is_new = FALSE;
                 }
             }
             if (!$user->loaded() and Arr::get($this->_config, 'create_user')) {
                 $user = $this->build_user($data, TRUE);
             }
             if (!$user) {
                 throw new Auth_Exception_Service('Service :service user with service uid :id does not exist and faild to create', array(':service' => $this->type(), ':id' => $this->service_uid()));
             }
             $user->set($this->_service_field, $this->service_uid());
             $user->save();
         } elseif (Arr::get($this->_config, 'update_user')) {
             $user->_is_new = FALSE;
             $user->load_service_values($this, $data, FALSE);
             $user->save();
         } else {
             $user->_is_new = FALSE;
         }
         return $user;
     }
     return FALSE;
 }
开发者ID:Konro1,项目名称:pms,代码行数:32,代码来源:Service.php


示例11: 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);
 }
开发者ID:openbuildings,项目名称:jam,代码行数:7,代码来源:SelectTest.php


示例12: initialize

 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     // All fields are aliased to different columns
     $meta->fields(array('id' => Jam::field('primary', array('column' => 'id-alias')), 'name' => Jam::field('string', array('column' => 'name-alias')), 'description' => Jam::field('string', array('column' => 'description-alias'))));
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Alias.php


示例13: 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);
 }
开发者ID:openbuildings,项目名称:promotions,代码行数:10,代码来源:PromotionTest.php


示例14: test_deep

 public function test_deep()
 {
     $blog = Jam::find_or_create('test_blog', array('id' => 10, 'name' => 'created blog'));
     $author = Jam::build('test_author')->load_fields(array('id' => 4, 'name' => 'Joe', 'test_posts' => array(array('id' => 1, 'name' => 'hardware', 'test_categories' => array(array('id' => 1, 'name' => 'cat1'), array('id' => 2, 'name' => 'cat2')), 'test_blog' => array('id' => 2, 'name' => 'loaded')), array('id' => 2, 'name' => 'software', 'test_categories' => array(array('id' => 1, 'name' => 'cat1'), array('id' => 3, 'name' => 'cat3')), 'test_blog' => 10))));
     $post = Jam::build('test_post')->load_fields(array('id' => 3, 'name' => 'administration'));
     $post2 = Jam::build('test_post', array('name' => 'unsaved'));
     $author->test_posts->add($post)->add($post2);
     $serialized_data = serialize($author);
     $unserialized = unserialize($serialized_data);
     $this->assertNotSame($author, $unserialized);
     $this->assertTrue($unserialized->loaded());
     $this->assertEquals($author->as_array(), $unserialized->as_array());
     $this->assertCount(4, $unserialized->test_posts);
     $this->assertTrue($unserialized->test_posts[0]->loaded());
     $this->assertEquals($author->test_posts[0]->as_array(), $unserialized->test_posts[0]->as_array());
     $this->assertNotNull($unserialized->test_posts[0]->test_blog);
     $this->assertTrue($unserialized->test_posts[0]->test_blog->loaded());
     $this->assertEquals($author->test_posts[0]->test_blog->as_array(), $unserialized->test_posts[0]->test_blog->as_array());
     $this->assertNotNull($unserialized->test_posts[1]->test_blog);
     $this->assertTrue($unserialized->test_posts[1]->test_blog->loaded());
     $this->assertEquals($author->test_posts[1]->test_blog->as_array(), $unserialized->test_posts[1]->test_blog->as_array());
     $this->assertEquals($blog->as_array(), $unserialized->test_posts[1]->test_blog->as_array());
     $this->assertTrue($unserialized->test_posts[1]->loaded());
     $this->assertEquals($author->test_posts[1]->as_array(), $unserialized->test_posts[1]->as_array());
     $this->assertTrue($unserialized->test_posts[2]->loaded());
     $this->assertEquals($author->test_posts[2]->as_array(), $unserialized->test_posts[2]->as_array());
     $this->assertFalse($unserialized->test_posts[3]->loaded());
     $this->assertEquals($author->test_posts[3]->as_array(), $unserialized->test_posts[3]->as_array());
     $blog->delete();
 }
开发者ID:Konro1,项目名称:pms,代码行数:30,代码来源:SerializeTest.php


示例15: test_validate

 /**
  * @covers Jam_Validator_Rule_Currency
  */
 public function test_validate()
 {
     $product = Jam::build('product', array('currency' => 'NNN'));
     $this->assertFalse($product->check());
     $product->currency = 'USD';
     $this->assertTrue($product->check());
 }
开发者ID:openbuildings,项目名称:jam-monetary,代码行数:10,代码来源:CurrencyTest.php


示例16: model_call_update_token

 public function model_call_update_token(Jam_Model $model, Jam_Event_Data $data)
 {
     do {
         $model->{$this->_field} = $this->new_token();
     } while (Jam::all($model->meta()->model())->where($this->_field, '=', $model->{$this->_field})->count_all() > 0);
     $data->return = $model;
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Tokenable.php


示例17: _load_token

 protected function _load_token($token)
 {
     if (!$token) {
         return NULL;
     }
     return is_object($token) ? $token : Jam::all('test_user_token')->valid_token($token)->first();
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Test.php


示例18: __construct

 public function __construct($id = NULL)
 {
     parent::__construct($id);
     if (mt_rand(1, 100) === 1) {
         Jam::delete($this)->expired()->execute();
     }
 }
开发者ID:Konro1,项目名称:pms,代码行数:7,代码来源:Token.php


示例19: test_model_before_check

 /**
  * @covers Jam_Behavior_Shippable_Purchase::model_before_check
  */
 public function test_model_before_check()
 {
     $purchase = Jam::build('purchase');
     $this->assertTrue($purchase->shipping_same_as_billing);
     $purchase->shipping_required = TRUE;
     $purchase->check();
     $this->assertEquals(array('billing_address' => array('present' => array())), $purchase->errors()->as_array());
     $purchase->billing_address = array('first_name' => 10);
     $purchase->check();
     $this->assertEquals(array('billing_address' => array('association' => array(':errors' => $purchase->billing_address->errors()))), $purchase->errors()->as_array());
     $purchase = Jam::build('purchase');
     $purchase->shipping_required = TRUE;
     $purchase->shipping_same_as_billing = FALSE;
     $purchase->check();
     $this->assertEquals(array('shipping_address' => array('present' => array())), $purchase->errors()->as_array());
     $purchase->shipping_address = array('first_name' => 10);
     $purchase->check();
     $this->assertEquals(array('shipping_address' => array('association' => array(':errors' => $purchase->shipping_address->errors()))), $purchase->errors()->as_array());
     $purchase = $this->getMock('Model_Purchase', array('items_count'), array('purchase'));
     $purchase->expects($this->exactly(2))->method('items_count')->with($this->equalTo(array('can_ship' => FALSE)))->will($this->onConsecutiveCalls(0, 1));
     $purchase->billing_address = array('first_name' => 'asd', 'last_name' => 'asd', 'email' => '[email protected]', 'line1' => 'asd', 'country' => 'France', 'city' => 'Paris', 'zip' => '123', 'phone' => '123');
     $purchase->shipping_required = TRUE;
     $purchase->check();
     $this->assertEquals(array(), $purchase->errors()->as_array());
     $purchase->check();
     $this->assertEquals(array('brand_purchases' => array('cannot_ship' => array())), $purchase->errors()->as_array());
 }
开发者ID:openbuildings,项目名称:shipping,代码行数:30,代码来源:PurchaseTest.php


示例20: test_render

    public function test_render()
    {
        $collection = Jam::all('test_city')->load_fields(array(array('id' => 1, 'name' => 'London', 'population' => 10), array('id' => 2, 'name' => 'New York', 'population' => 15)));
        $name = new Tart_Column();
        $name->sort(FALSE);
        $population = new Tart_Column();
        $population->sort(FALSE);
        $columns = array('name' => $name, 'population' => $population);
        $table = new Tart_Table($collection, $columns);
        $table->selected(FALSE);
        $expected = <<<HTML
<table class="table table-striped table-hover">
  <thead>
    <th>Name</th>
    <th>Population</th>
  </thead>
  <tbody>
    <tr class="test_city-1">
      <td>London</td>
      <td>10</td>
    </tr>
    <tr class="test_city-2">
      <td>New York</td>
      <td>15</td>
    </tr>
  </tbody>
</table>
HTML;
        $this->assertSame($expected, $table->render());
        $table->selected(array(1));
        $expected = <<<HTML_SELECTED
<table class="table table-striped table-hover">
  <thead>
    <th width="10">
      <input type="checkbox" name="all" value="1"/>
    </th>
    <th>Name</th>
    <th>Population</th>
  </thead>
  <tbody>
    <tr class="test_city-1">
      <td>
        <input type="checkbox" name="id[]" value="1" checked="1"/>
      </td>
      <td>London</td>
      <td>10</td>
    </tr>
    <tr class="test_city-2">
      <td>
        <input type="checkbox" name="id[]" value="2"/>
      </td>
      <td>New York</td>
      <td>15</td>
    </tr>
  </tbody>
</table>
HTML_SELECTED;
        $this->assertSame($expected, $table->render());
    }
开发者ID:openbuildings,项目名称:jam-tart,代码行数:59,代码来源:tableTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JavaScriptHelper类代码示例发布时间:2022-05-23
下一篇:
PHP JWT类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap