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


PHP Test::table方法代碼示例

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


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

示例1: testTable

 function testTable()
 {
     $tb = Test::table();
     $new_data = ['nickname' => 'z3'];
     $tb->insert($new_data);
     $this->assertEquals(1, $tb->count());
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $update = $tb->update(['nickname' => 'w5']);
     $this->assertEquals(1, $update);
     $this->assertEquals([['nickname' => 'w5']], $tb->selectData());
     $tb_new = clone $tb;
     $tb_new->where('nickname=%s', 'w5');
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $tb_new->clearWhere();
     $tb_new->andWhere(['nickname' => 'w5']);
     //$this->assertEquals('SELEC', $tb->buildSelect());
     $this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
     $this->assertEquals(1, $tb_new->update(['nickname' => 'z3']));
     $this->assertEquals([['nickname' => 'z3']], $tb->selectData());
     $obj_list = $tb->select();
     $obj = $obj_list[0];
     /* @var $obj Test */
     $this->assertEquals('z3', $obj->nickname);
     $tb->delete();
     $test = new Test();
     $test->nickname = 'hehe';
     $this->assertEquals(TRUE, $test->save());
     $this->assertEquals('hehe', Test::table()->selectData()[0]['nickname']);
     $test->delete();
     $this->assertEquals([], $tb->selectData());
     $this->assertEquals('SELECT * FROM test Test', $tb->buildSelect());
     $this->assertEquals('SELECT * FROM test Test LIMIT 10', $tb->buildSelect(10));
     $this->assertEquals('SELECT * FROM test Test LIMIT 10 OFFSET 10', $tb->buildSelect(10, 10));
 }
開發者ID:kasonyang,項目名稱:hitar,代碼行數:35,代碼來源:TableTest.php

示例2: init

function init()
{
    $tb = Test::table();
    $sm = $tb->getConnection()->getSchemaManager();
    $schema = $sm->createSchema();
    $new_tb = $schema->createTable('test');
    $new_tb->addColumn('nickname', 'string', ['length' => 100]);
    $new_tb2 = $schema->createTable('tableexample');
    $new_tb2->addColumn('id', 'string', ['length' => 100]);
    $new_tb2->addColumn('name', 'string', ['length' => 100]);
    $sqls = $schema->toSql($tb->getConnection()->getDatabasePlatform());
    foreach ($sqls as $q) {
        $tb->getConnection()->exec($q);
    }
}
開發者ID:kasonyang,項目名稱:hitar,代碼行數:15,代碼來源:initTest.php

示例3: testRecord

 function testRecord()
 {
     $this->assertEquals('test', Test::table()->getTableName());
     $this->assertEquals('Test', Test::table()->getTableAliasName());
 }
開發者ID:kasonyang,項目名稱:hitar,代碼行數:5,代碼來源:RecordTest.php


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