transactd 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/common/{tdclc_32_3_5.dll → tdclc_32_3_6.dll} +0 -0
- data/bin/common/tdclc_64_3_6.dll +0 -0
- data/build/swig/ruby/tdclrb_wrap.cpp +12524 -24430
- data/build/swig/tdcl.i +5 -0
- data/build/tdclc/tdclc.cbproj +1 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/engine/mysql/database.cpp +210 -184
- data/source/bzs/db/engine/mysql/database.h +276 -105
- data/source/bzs/db/engine/mysql/mysqlInternal.h +37 -0
- data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +1 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +4 -4
- data/source/bzs/db/protocol/tdap/client/activeTable.h +1 -1
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +1 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +7 -4
- data/source/bzs/db/protocol/tdap/client/database.h +6 -1
- data/source/bzs/db/protocol/tdap/client/databaseManager.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +21 -9
- data/source/bzs/db/protocol/tdap/client/dbDef.h +1 -1
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +10 -2
- data/source/bzs/db/protocol/tdap/client/field.cpp +29 -5
- data/source/bzs/db/protocol/tdap/client/field.h +3 -1
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.cpp +5 -0
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.h +1 -0
- data/source/bzs/db/protocol/tdap/client/fields.h +9 -2
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +8 -4
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +18 -5
- data/source/bzs/db/protocol/tdap/client/memRecord.h +2 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +46 -13
- data/source/bzs/db/protocol/tdap/client/nsTable.h +5 -0
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +5 -0
- data/source/bzs/db/protocol/tdap/client/recordset.h +1 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +6 -2
- data/source/bzs/db/protocol/tdap/client/request.h +46 -38
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -3
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +29 -13
- data/source/bzs/db/protocol/tdap/client/table.cpp +60 -10
- data/source/bzs/db/protocol/tdap/client/table.h +4 -1
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +18 -1
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +10 -4
- data/source/bzs/db/protocol/tdap/fieldComp.h +1 -1
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +1 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +11 -4
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +2 -1
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +52 -94
- data/source/bzs/db/protocol/tdap/mysql/request.h +20 -13
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +92 -60
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +4 -4
- data/source/bzs/db/protocol/tdap/tdapRequest.h +11 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +83 -34
- data/source/bzs/db/protocol/tdap/tdapSchema.h +5 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +7 -3
- data/source/bzs/example/ormap_c.cpp +2 -2
- data/source/bzs/netsvc/server/serverPipe.cpp +35 -1
- data/source/bzs/test/tdclatl/test_v3.js +48 -1
- data/source/bzs/test/tdclphp/bench.php +89 -76
- data/source/bzs/test/tdclphp/transactd_Test.php +691 -687
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +46 -43
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +46 -43
- data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +33 -33
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +29 -25
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +653 -183
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +40 -4
- data/source/bzs/test/tdclrb/transactd_fetch_spec.rb +785 -0
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +21 -1
- data/source/bzs/test/tdclrb/transactd_setget_spec.rb +450 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +14 -2
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +1192 -11
- data/source/bzs/test/trdclengn/testField.h +522 -1
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +37 -1
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +62 -4
- data/source/global/tdclatl/RecordsetQuery.cpp +2 -1
- data/source/global/tdclatl/RecordsetQuery.h +1 -1
- data/source/global/tdclatl/Table.cpp +17 -0
- data/source/global/tdclatl/Table.h +3 -1
- data/source/global/tdclatl/tdclatl.idl +7 -2
- data/transactd.gemspec +1 -1
- metadata +7 -5
- data/bin/common/tdclc_64_3_5.dll +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/* ================================================================
|
|
3
|
-
Copyright (C) 2013 BizStation Corp All rights reserved.
|
|
3
|
+
Copyright (C) 2013,2016 BizStation Corp All rights reserved.
|
|
4
4
|
|
|
5
5
|
This program is free software; you can redistribute it and/or
|
|
6
6
|
modify it under the terms of the GNU General Public License
|
|
@@ -13,24 +13,27 @@
|
|
|
13
13
|
GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program; if not, write to the Free Software
|
|
17
|
-
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
18
18
|
02111-1307, USA.
|
|
19
19
|
================================================================ */
|
|
20
|
-
mb_internal_encoding('UTF-8');
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
require("transactd.php");
|
|
22
|
+
|
|
23
|
+
use BizStation\Transactd\Transactd;
|
|
24
|
+
use BizStation\Transactd\Tabledef;
|
|
25
|
+
use BizStation\Transactd\Database;
|
|
26
|
+
use BizStation\Transactd\Table;
|
|
27
|
+
use BizStation\Transactd\Query;
|
|
28
|
+
use BizStation\Transactd\ActiveTable;
|
|
24
29
|
|
|
25
30
|
function getHost()
|
|
26
31
|
{
|
|
27
32
|
$host = getenv('TRANSACTD_PHPUNIT_HOST');
|
|
28
|
-
if (strlen($host) == 0)
|
|
29
|
-
{
|
|
33
|
+
if (strlen($host) == 0) {
|
|
30
34
|
$host = '127.0.0.1/';
|
|
31
35
|
}
|
|
32
|
-
if ($host[strlen($host) - 1] != '/')
|
|
33
|
-
{
|
|
36
|
+
if ($host[strlen($host) - 1] != '/') {
|
|
34
37
|
$host = $host . '/';
|
|
35
38
|
}
|
|
36
39
|
return $host;
|
|
@@ -48,7 +51,7 @@ define("FDI_USER_ID", 1);
|
|
|
48
51
|
define("FDI_BODY", 2);
|
|
49
52
|
define("FDI_IMAGE", 3);
|
|
50
53
|
|
|
51
|
-
class
|
|
54
|
+
class TransactdBlobTest extends PHPUnit_Framework_TestCase
|
|
52
55
|
{
|
|
53
56
|
private function dropDatabase($db, $url)
|
|
54
57
|
{
|
|
@@ -60,8 +63,7 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
60
63
|
private function createDatabase($db, $url)
|
|
61
64
|
{
|
|
62
65
|
$db->create($url);
|
|
63
|
-
if ($db->stat() ==
|
|
64
|
-
{
|
|
66
|
+
if ($db->stat() == Transactd::STATUS_TABLE_EXISTS_ERROR) {
|
|
65
67
|
$this->dropDatabase($db, $url);
|
|
66
68
|
$db->create($url);
|
|
67
69
|
$this->assertEquals($db->stat(), 0);
|
|
@@ -70,22 +72,22 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
70
72
|
}
|
|
71
73
|
private function openDatabase($db, $url)
|
|
72
74
|
{
|
|
73
|
-
$db->open($url,
|
|
75
|
+
$db->open($url, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL);
|
|
74
76
|
$this->assertEquals($db->stat(), 0);
|
|
75
77
|
}
|
|
76
78
|
private function createTable($db, $tableid, $tablename)
|
|
77
79
|
{
|
|
78
80
|
$dbdef = $db->dbDef();
|
|
79
|
-
$this->assertNotEquals($dbdef,
|
|
80
|
-
$td = new
|
|
81
|
+
$this->assertNotEquals($dbdef, null);
|
|
82
|
+
$td = new Tabledef();
|
|
81
83
|
// Set table schema codepage to UTF-8
|
|
82
84
|
// - codepage for field NAME and tableNAME
|
|
83
|
-
$td->schemaCodePage =
|
|
85
|
+
$td->schemaCodePage = Transactd::CP_UTF8;
|
|
84
86
|
$td->setTableName($tablename);
|
|
85
87
|
$td->setFileName($tablename . '.dat');
|
|
86
88
|
// Set table default charaset index
|
|
87
89
|
// - default charset for field VALUE
|
|
88
|
-
$td->charsetIndex =
|
|
90
|
+
$td->charsetIndex = Transactd::charsetIndex(Transactd::CP_UTF8);
|
|
89
91
|
//
|
|
90
92
|
$td->id = $tableid;
|
|
91
93
|
$td->pageSize = 2048;
|
|
@@ -94,28 +96,28 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
94
96
|
// id
|
|
95
97
|
$fd = $dbdef->insertField($tableid, FDI_ID);
|
|
96
98
|
$fd->setName('id');
|
|
97
|
-
$fd->type =
|
|
99
|
+
$fd->type = Transactd::ft_autoinc;
|
|
98
100
|
$fd->len = 4;
|
|
99
101
|
$dbdef->updateTableDef($tableid);
|
|
100
102
|
$this->assertEquals($dbdef->stat(), 0);
|
|
101
103
|
// user_id
|
|
102
104
|
$fd = $dbdef->insertField($tableid, FDI_USER_ID);
|
|
103
105
|
$fd->setName('user_id');
|
|
104
|
-
$fd->type =
|
|
106
|
+
$fd->type = Transactd::ft_integer;
|
|
105
107
|
$fd->len = 4;
|
|
106
108
|
$dbdef->updateTableDef($tableid);
|
|
107
109
|
$this->assertEquals($dbdef->stat(), 0);
|
|
108
110
|
// body
|
|
109
111
|
$fd = $dbdef->insertField($tableid, FDI_BODY);
|
|
110
112
|
$fd->setName('body');
|
|
111
|
-
$fd->type =
|
|
113
|
+
$fd->type = Transactd::ft_mytext;
|
|
112
114
|
$fd->len = 10; // 9:TYNYTEXT 10:TEXT 11:MIDIUMTEXT 12:LONGTEXT
|
|
113
115
|
$dbdef->updateTableDef($tableid);
|
|
114
116
|
$this->assertEquals($dbdef->stat(), 0);
|
|
115
117
|
// image
|
|
116
118
|
$fd = $dbdef->insertField($tableid, FDI_IMAGE);
|
|
117
119
|
$fd->setName('image');
|
|
118
|
-
$fd->type =
|
|
120
|
+
$fd->type = Transactd::ft_myblob;
|
|
119
121
|
$fd->len = 10; // 9:TYNYBLOB 10:BLOB 11:MIDIUMBLOB 12:LONGBLOB
|
|
120
122
|
$dbdef->updateTableDef($tableid);
|
|
121
123
|
$this->assertEquals($dbdef->stat(), 0);
|
|
@@ -134,27 +136,28 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
134
136
|
$this->assertEquals($db->stat(), 0);
|
|
135
137
|
return $tb;
|
|
136
138
|
}
|
|
137
|
-
private function getTestBinary()
|
|
139
|
+
private function getTestBinary()
|
|
140
|
+
{
|
|
138
141
|
$image_base64 = 'R0lGODdhEAAQAKEBAGZmZv///5mZmczMzCwAAAAAEAAQAAACRowzIgA6BxebTMAgG60nW5NM1kAZikGFHAmgYvYgJpW12FfTyLpJjz+IVSSXR4IlQCoUgCCG8ds0D5xZT3TJYS8IZiMJKQAAOw==';
|
|
139
142
|
return base64_decode($image_base64);
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
public function testCreate()
|
|
143
146
|
{
|
|
144
|
-
$db = new
|
|
147
|
+
$db = new Database();
|
|
145
148
|
$this->createDatabase($db, URL);
|
|
146
149
|
$this->openDatabase($db, URL);
|
|
147
150
|
$this->createTable($db, 1, TABLENAME);
|
|
148
|
-
$
|
|
151
|
+
$this->openTable($db, TABLENAME);
|
|
149
152
|
$db->close();
|
|
150
153
|
}
|
|
151
154
|
public function testInsert()
|
|
152
155
|
{
|
|
153
156
|
$image = $this->getTestBinary();
|
|
154
|
-
$db = new
|
|
157
|
+
$db = new Database();
|
|
155
158
|
$this->openDatabase($db, URL);
|
|
156
159
|
$tb = $this->openTable($db, TABLENAME);
|
|
157
|
-
$this->assertNotEquals($tb,
|
|
160
|
+
$this->assertNotEquals($tb, null);
|
|
158
161
|
// 1
|
|
159
162
|
$tb->clearBuffer();
|
|
160
163
|
$tb->setFV(FDI_USER_ID, 1);
|
|
@@ -182,10 +185,10 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
182
185
|
}
|
|
183
186
|
public function testSeek()
|
|
184
187
|
{
|
|
185
|
-
$db = new
|
|
188
|
+
$db = new Database();
|
|
186
189
|
$this->openDatabase($db, URL);
|
|
187
190
|
$tb = $this->openTable($db, TABLENAME);
|
|
188
|
-
$this->assertNotEquals($tb,
|
|
191
|
+
$this->assertNotEquals($tb, null);
|
|
189
192
|
// 1
|
|
190
193
|
$tb->clearBuffer();
|
|
191
194
|
$tb->setFV(FDI_ID, 1);
|
|
@@ -217,17 +220,17 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
217
220
|
}
|
|
218
221
|
public function testFind()
|
|
219
222
|
{
|
|
220
|
-
$db = new
|
|
223
|
+
$db = new Database();
|
|
221
224
|
$this->openDatabase($db, URL);
|
|
222
225
|
$tb = $this->openTable($db, TABLENAME);
|
|
223
|
-
$this->assertNotEquals($tb,
|
|
226
|
+
$this->assertNotEquals($tb, null);
|
|
224
227
|
// 1
|
|
225
228
|
$tb->setKeyNum(0);
|
|
226
229
|
$tb->clearBuffer();
|
|
227
230
|
$tb->setFilter('id >= 1 and id < 3', 1, 0);
|
|
228
231
|
$this->assertEquals($tb->stat(), 0);
|
|
229
232
|
$tb->setFV(FDI_ID, 1);
|
|
230
|
-
$tb->find(
|
|
233
|
+
$tb->find(Table::findForword);
|
|
231
234
|
$this->assertEquals($tb->stat(), 0);
|
|
232
235
|
$this->assertEquals($tb->getFVint(FDI_ID), 1);
|
|
233
236
|
$this->assertEquals($tb->getFVint(FDI_USER_ID), 1);
|
|
@@ -240,15 +243,15 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
240
243
|
$this->assertEquals($tb->getFVstr(FDI_BODY), "2\ntest\nテスト\n\nあいうえおあいうえお");
|
|
241
244
|
// 3... but not found because filtered
|
|
242
245
|
$tb->findNext(true);
|
|
243
|
-
$this->assertEquals($tb->stat(),
|
|
246
|
+
$this->assertEquals($tb->stat(), Transactd::STATUS_EOF);
|
|
244
247
|
$db->close();
|
|
245
248
|
}
|
|
246
249
|
public function testUpdate()
|
|
247
250
|
{
|
|
248
|
-
$db = new
|
|
251
|
+
$db = new Database();
|
|
249
252
|
$this->openDatabase($db, URL);
|
|
250
253
|
$tb = $this->openTable($db, TABLENAME);
|
|
251
|
-
$this->assertNotEquals($tb,
|
|
254
|
+
$this->assertNotEquals($tb, null);
|
|
252
255
|
// select 1
|
|
253
256
|
$tb->clearBuffer();
|
|
254
257
|
$tb->setFV(FDI_ID, 1);
|
|
@@ -283,10 +286,10 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
283
286
|
}
|
|
284
287
|
public function testDelete()
|
|
285
288
|
{
|
|
286
|
-
$db = new
|
|
289
|
+
$db = new Database();
|
|
287
290
|
$this->openDatabase($db, URL);
|
|
288
291
|
$tb = $this->openTable($db, TABLENAME);
|
|
289
|
-
$this->assertNotEquals($tb,
|
|
292
|
+
$this->assertNotEquals($tb, null);
|
|
290
293
|
// delete 2
|
|
291
294
|
$tb->clearBuffer();
|
|
292
295
|
$tb->setFV(FDI_ID, 2);
|
|
@@ -308,26 +311,26 @@ class transactdBlobTest extends PHPUnit_Framework_TestCase
|
|
|
308
311
|
$this->assertEquals($tb->getFVstr(FDI_BODY), "3\ntest\nテスト\n\nあいうえおあいうえお");
|
|
309
312
|
// eof
|
|
310
313
|
$tb->seekNext();
|
|
311
|
-
$this->assertEquals($tb->stat(),
|
|
314
|
+
$this->assertEquals($tb->stat(), Transactd::STATUS_EOF);
|
|
312
315
|
$db->close();
|
|
313
316
|
}
|
|
314
317
|
public function testRecord()
|
|
315
318
|
{
|
|
316
319
|
$image = $this->getTestBinary();
|
|
317
|
-
$db = new
|
|
320
|
+
$db = new Database();
|
|
318
321
|
$this->openDatabase($db, URL);
|
|
319
|
-
$at = new
|
|
320
|
-
$q = new
|
|
322
|
+
$at = new ActiveTable($db, TABLENAME);
|
|
323
|
+
$q = new Query();
|
|
321
324
|
$q->where('id', '=', 1);
|
|
322
325
|
$rs = $at->index(0)->keyValue(1)->read($q);
|
|
323
326
|
$this->assertEquals(count($rs), 1);
|
|
324
|
-
$f = $rs
|
|
327
|
+
$f = $rs->getRecord(0)->getField(FDI_IMAGE);
|
|
325
328
|
$this->assertEquals($f->getBin(), $image);
|
|
326
329
|
$db->close();
|
|
327
330
|
}
|
|
328
331
|
public function testDrop()
|
|
329
332
|
{
|
|
330
|
-
$db = new
|
|
333
|
+
$db = new Database();
|
|
331
334
|
$this->dropDatabase($db, URL);
|
|
332
335
|
}
|
|
333
336
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/* ================================================================
|
|
3
|
-
Copyright (C) 2013 BizStation Corp All rights reserved.
|
|
3
|
+
Copyright (C) 2013,2016 BizStation Corp All rights reserved.
|
|
4
4
|
|
|
5
5
|
This program is free software; you can redistribute it and/or
|
|
6
6
|
modify it under the terms of the GNU General Public License
|
|
@@ -17,25 +17,28 @@
|
|
|
17
17
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
18
18
|
02111-1307, USA.
|
|
19
19
|
================================================================ */
|
|
20
|
-
mb_internal_encoding('UTF-8');
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
use BizStation\Transactd as Bz;
|
|
21
|
+
require("transactd.php");
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
use BizStation\Transactd\Transactd;
|
|
24
|
+
use BizStation\Transactd\BtrTime;
|
|
25
|
+
use BizStation\Transactd\BtrDate;
|
|
26
|
+
use BizStation\Transactd\BtrTimeStamp;
|
|
27
|
+
|
|
28
|
+
class TransactdDatetimeTest extends PHPUnit_Framework_TestCase
|
|
26
29
|
{
|
|
27
30
|
public function testGetBtrdate()
|
|
28
31
|
{
|
|
29
|
-
$i_nowdate =
|
|
30
|
-
$s_i_nowdate =
|
|
31
|
-
$s_i_nowdate2 =
|
|
32
|
+
$i_nowdate = Transactd::getNowDate(); // get today as integer
|
|
33
|
+
$s_i_nowdate = Transactd::btrdtoa($i_nowdate);
|
|
34
|
+
$s_i_nowdate2 = Transactd::btrdtoa($i_nowdate, true);
|
|
32
35
|
//print_r($i_nowdate);
|
|
33
36
|
//print_r($s_i_nowdate);
|
|
34
37
|
//print_r($s_i_nowdate2);
|
|
35
|
-
$nowdate = new
|
|
38
|
+
$nowdate = new BtrDate();
|
|
36
39
|
$nowdate->i = $i_nowdate; // get today as BtrDate
|
|
37
|
-
$s_nowdate =
|
|
38
|
-
$s_nowdate2 =
|
|
40
|
+
$s_nowdate = Transactd::btrdtoa($nowdate);
|
|
41
|
+
$s_nowdate2 = Transactd::btrdtoa($nowdate, true);
|
|
39
42
|
//print_r($nowdate);
|
|
40
43
|
//print_r($s_nowdate);
|
|
41
44
|
//print_r($s_nowdate2);
|
|
@@ -44,48 +47,48 @@ class transactdDatetimeTest extends PHPUnit_Framework_TestCase
|
|
|
44
47
|
}
|
|
45
48
|
public function testGetBtrtime()
|
|
46
49
|
{
|
|
47
|
-
$i_nowtime =
|
|
48
|
-
$s_i_nowtime =
|
|
50
|
+
$i_nowtime = Transactd::getNowTime(); // get now time as integer
|
|
51
|
+
$s_i_nowtime = Transactd::btrttoa($i_nowtime);
|
|
49
52
|
//print_r($i_nowtime);
|
|
50
53
|
//print_r($s_i_nowtime);
|
|
51
|
-
$nowtime = new
|
|
54
|
+
$nowtime = new BtrTime();
|
|
52
55
|
$nowtime->i = $i_nowtime; // get now time as BtrTime
|
|
53
|
-
$s_nowtime =
|
|
56
|
+
$s_nowtime = Transactd::btrttoa($nowtime);
|
|
54
57
|
//print_r($nowtime);
|
|
55
58
|
//print_r($s_nowtime);
|
|
56
59
|
$this->assertEquals($s_i_nowtime, $s_nowtime);
|
|
57
60
|
}
|
|
58
61
|
public function testGetBtrdatetime()
|
|
59
62
|
{
|
|
60
|
-
$d =
|
|
63
|
+
$d = Transactd::atobtrd("2012-08-22");
|
|
61
64
|
//print_r($d);
|
|
62
|
-
$s_date =
|
|
65
|
+
$s_date = Transactd::btrdtoa($d);
|
|
63
66
|
$this->assertEquals($s_date, '2012/08/22');
|
|
64
67
|
//print_r($s_date);
|
|
65
|
-
$t =
|
|
66
|
-
$s_time =
|
|
68
|
+
$t = Transactd::atobtrt("15:37:00");
|
|
69
|
+
$s_time = Transactd::btrttoa($t);
|
|
67
70
|
$this->assertEquals($s_time, '15:37:00');
|
|
68
71
|
//print_r($t);
|
|
69
72
|
//print_r($s_time);
|
|
70
|
-
$dt =
|
|
71
|
-
$s_datetime =
|
|
72
|
-
$s_datetime2 =
|
|
73
|
+
$dt = Transactd::atobtrs('2012-08-22 15:37:00');
|
|
74
|
+
$s_datetime = Transactd::btrstoa($dt);
|
|
75
|
+
$s_datetime2 = Transactd::btrstoa($dt, true);
|
|
73
76
|
$this->assertEquals($s_datetime, '2012/08/22 15:37:00');
|
|
74
77
|
$this->assertEquals($s_datetime2, '2012-08-22T15:37:00');
|
|
75
78
|
//print_r($dt);
|
|
76
79
|
//print_r($s_datetime);
|
|
77
80
|
//print_r($s_datetime2);
|
|
78
|
-
$s_datetime_d =
|
|
79
|
-
$s_datetime_t =
|
|
81
|
+
$s_datetime_d = Transactd::btrdtoa($dt->date);
|
|
82
|
+
$s_datetime_t = Transactd::btrttoa($dt->time);
|
|
80
83
|
$this->assertEquals($s_datetime_d . ' ' . $s_datetime_t, '2012/08/22 15:37:00');
|
|
81
84
|
//print_r($s_datetime_d . ' ' . $s_datetime_t);
|
|
82
85
|
}
|
|
83
86
|
public function testGetBtrtimestampFromString()
|
|
84
87
|
{
|
|
85
|
-
$d =
|
|
86
|
-
$t =
|
|
87
|
-
$btrts = new
|
|
88
|
-
$btrts2 = new
|
|
88
|
+
$d = Transactd::atobtrd('2012-08-22');
|
|
89
|
+
$t = Transactd::atobtrt('15:37:00');
|
|
90
|
+
$btrts = new BtrTimeStamp('2012-08-22 15:37:00');
|
|
91
|
+
$btrts2 = new BtrTimeStamp($d, $t);
|
|
89
92
|
$s_btrts = $btrts->toString();
|
|
90
93
|
$s_btrts2 = $btrts2->toString();
|
|
91
94
|
//print_r($btrts);
|
|
@@ -97,15 +100,15 @@ class transactdDatetimeTest extends PHPUnit_Framework_TestCase
|
|
|
97
100
|
}
|
|
98
101
|
public function testGetBtrtimestampFromBtrdateAndBtrtime()
|
|
99
102
|
{
|
|
100
|
-
$i_nowdate =
|
|
101
|
-
$nowdate = new
|
|
103
|
+
$i_nowdate = Transactd::getNowDate();
|
|
104
|
+
$nowdate = new BtrDate();
|
|
102
105
|
$nowdate->i = $i_nowdate;
|
|
103
|
-
$i_nowtime =
|
|
104
|
-
$nowtime = new
|
|
106
|
+
$i_nowtime = Transactd::getNowTime();
|
|
107
|
+
$nowtime = new BtrTime();
|
|
105
108
|
$nowtime->i = $i_nowtime;
|
|
106
|
-
$nowdatetime = new
|
|
107
|
-
$s_nowdate =
|
|
108
|
-
$s_nowtime =
|
|
109
|
+
$nowdatetime = new BtrTimeStamp($nowdate, $nowtime);
|
|
110
|
+
$s_nowdate = Transactd::btrdtoa($nowdate);
|
|
111
|
+
$s_nowtime = Transactd::btrttoa($nowtime);
|
|
109
112
|
$s_nowdatetime = $nowdatetime->toString();
|
|
110
113
|
$this->assertEquals($s_nowdatetime, $s_nowdate . ' ' . $s_nowtime);
|
|
111
114
|
//print_r($nowdatetime);
|
|
@@ -114,20 +117,20 @@ class transactdDatetimeTest extends PHPUnit_Framework_TestCase
|
|
|
114
117
|
}
|
|
115
118
|
public function testLastYear()
|
|
116
119
|
{
|
|
117
|
-
$i_nowdate =
|
|
118
|
-
$nowdate = new
|
|
120
|
+
$i_nowdate = Transactd::getNowDate();
|
|
121
|
+
$nowdate = new BtrDate();
|
|
119
122
|
$nowdate->i = $i_nowdate;
|
|
120
123
|
$nowyear_yy = $nowdate->yy;
|
|
121
|
-
$i_nowtime =
|
|
122
|
-
$nowtime = new
|
|
124
|
+
$i_nowtime = Transactd::getNowTime();
|
|
125
|
+
$nowtime = new BtrTime();
|
|
123
126
|
$nowtime->i = $i_nowtime;
|
|
124
|
-
$nowdatetime = new
|
|
127
|
+
$nowdatetime = new BtrTimeStamp($nowdate, $nowtime);
|
|
125
128
|
$s_nowdatetime = $nowdatetime->toString();
|
|
126
129
|
$lastyear = $nowdate;
|
|
127
130
|
$lastyear->yy = $lastyear->yy - 1;
|
|
128
131
|
$lastyear_yy = $lastyear->yy;
|
|
129
|
-
$s_lastyear =
|
|
130
|
-
$lastyeardatetime = new
|
|
132
|
+
$s_lastyear = Transactd::btrdtoa($lastyear);
|
|
133
|
+
$lastyeardatetime = new BtrTimeStamp($lastyear, $nowtime);
|
|
131
134
|
$s_lastyeardatetime = $lastyeardatetime->toString();
|
|
132
135
|
$this->assertEquals($nowyear_yy - 1, $lastyear_yy);
|
|
133
136
|
$this->assertEquals($s_lastyeardatetime, str_replace($nowyear_yy, $lastyear_yy, $s_nowdatetime));
|
|
@@ -137,7 +140,7 @@ class transactdDatetimeTest extends PHPUnit_Framework_TestCase
|
|
|
137
140
|
}
|
|
138
141
|
public function testTypename()
|
|
139
142
|
{
|
|
140
|
-
$typename =
|
|
143
|
+
$typename = Transactd::getTypeName(Transactd::ft_integer);
|
|
141
144
|
//print_r($typename);
|
|
142
145
|
$this->assertEquals($typename, 'Integer');
|
|
143
146
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
/* ================================================================
|
|
3
|
-
Copyright (C) 2013 BizStation Corp All rights reserved.
|
|
3
|
+
Copyright (C) 2013,2016 BizStation Corp All rights reserved.
|
|
4
4
|
|
|
5
5
|
This program is free software; you can redistribute it and/or
|
|
6
6
|
modify it under the terms of the GNU General Public License
|
|
@@ -13,24 +13,25 @@
|
|
|
13
13
|
GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program; if not, write to the Free Software
|
|
17
|
-
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
18
18
|
02111-1307, USA.
|
|
19
19
|
================================================================ */
|
|
20
|
-
mb_internal_encoding('UTF-8');
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
require("transactd.php");
|
|
22
|
+
|
|
23
|
+
use BizStation\Transactd\Transactd;
|
|
24
|
+
use BizStation\Transactd\Tabledef;
|
|
25
|
+
use BizStation\Transactd\Database;
|
|
26
|
+
use BizStation\Transactd\Table;
|
|
24
27
|
|
|
25
28
|
function getHost()
|
|
26
29
|
{
|
|
27
30
|
$host = getenv('TRANSACTD_PHPUNIT_HOST');
|
|
28
|
-
if (strlen($host) == 0)
|
|
29
|
-
{
|
|
31
|
+
if (strlen($host) == 0) {
|
|
30
32
|
$host = '127.0.0.1/';
|
|
31
33
|
}
|
|
32
|
-
if ($host[strlen($host) - 1] != '/')
|
|
33
|
-
{
|
|
34
|
+
if ($host[strlen($host) - 1] != '/') {
|
|
34
35
|
$host = $host . '/';
|
|
35
36
|
}
|
|
36
37
|
return $host;
|
|
@@ -48,7 +49,7 @@ define("FDN_ID", "番号");
|
|
|
48
49
|
define("FDI_NAME", 1);
|
|
49
50
|
define("FDN_NAME", "名前");
|
|
50
51
|
|
|
51
|
-
class
|
|
52
|
+
class TransactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
52
53
|
{
|
|
53
54
|
private function dropDatabase($db, $url)
|
|
54
55
|
{
|
|
@@ -60,8 +61,7 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
60
61
|
private function createDatabase($db, $url)
|
|
61
62
|
{
|
|
62
63
|
$db->create($url);
|
|
63
|
-
if ($db->stat() ==
|
|
64
|
-
{
|
|
64
|
+
if ($db->stat() == Transactd::STATUS_TABLE_EXISTS_ERROR) {
|
|
65
65
|
$this->dropDatabase($db, $url);
|
|
66
66
|
$db->create($url);
|
|
67
67
|
}
|
|
@@ -69,22 +69,22 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
69
69
|
}
|
|
70
70
|
private function openDatabase($db, $url)
|
|
71
71
|
{
|
|
72
|
-
$db->open($url,
|
|
72
|
+
$db->open($url, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL);
|
|
73
73
|
$this->assertEquals($db->stat(), 0);
|
|
74
74
|
}
|
|
75
75
|
private function createTable($db, $tableid, $tablename)
|
|
76
76
|
{
|
|
77
77
|
$dbdef = $db->dbDef();
|
|
78
|
-
$this->assertNotEquals($dbdef,
|
|
79
|
-
$td = new
|
|
78
|
+
$this->assertNotEquals($dbdef, null);
|
|
79
|
+
$td = new Tabledef();
|
|
80
80
|
/* Set table schema codepage to UTF-8
|
|
81
81
|
- codepage for field NAME and tableNAME */
|
|
82
|
-
$td->schemaCodePage =
|
|
82
|
+
$td->schemaCodePage = Transactd::CP_UTF8;
|
|
83
83
|
$td->setTableName($tablename);
|
|
84
84
|
$td->setFileName($tablename . '.dat');
|
|
85
85
|
/* Set table default charaset index
|
|
86
86
|
- default charset for field VALUE */
|
|
87
|
-
$td->charsetIndex =
|
|
87
|
+
$td->charsetIndex = Transactd::charsetIndex(Transactd::CP_UTF8);
|
|
88
88
|
//
|
|
89
89
|
$td->id = $tableid;
|
|
90
90
|
$td->pageSize = 2048;
|
|
@@ -92,19 +92,19 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
92
92
|
$this->assertEquals($dbdef->stat(), 0);
|
|
93
93
|
$fd = $dbdef->insertField($tableid, FDI_ID);
|
|
94
94
|
$fd->setName(FDN_ID);
|
|
95
|
-
$fd->type =
|
|
95
|
+
$fd->type = Transactd::ft_integer;
|
|
96
96
|
$fd->len = 4;
|
|
97
97
|
$dbdef->updateTableDef($tableid);
|
|
98
98
|
$this->assertEquals($dbdef->stat(), 0);
|
|
99
99
|
$fd = $dbdef->insertField($tableid, FDI_NAME);
|
|
100
100
|
$fd->setName(FDN_NAME);
|
|
101
|
-
$fd->type =
|
|
101
|
+
$fd->type = Transactd::ft_zstring;
|
|
102
102
|
$fd->len = 33;
|
|
103
103
|
$dbdef->updateTableDef($tableid);
|
|
104
104
|
$this->assertEquals($dbdef->stat(), 0);
|
|
105
105
|
/* Set field charset index
|
|
106
106
|
- charset for each field VALUE
|
|
107
|
-
$fd->setCharsetIndex(
|
|
107
|
+
$fd->setCharsetIndex(Transactd::charsetIndex(Transactd::CP_UTF8)) */
|
|
108
108
|
$kd = $dbdef->insertKey($tableid, 0);
|
|
109
109
|
$kd->segment(0)->fieldNum = 0;
|
|
110
110
|
$kd->segment(0)->flags->bit8 = 1;
|
|
@@ -122,7 +122,7 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
122
122
|
private function insert($db, $tablename)
|
|
123
123
|
{
|
|
124
124
|
$tb = $this->openTable($db, $tablename);
|
|
125
|
-
$this->assertNotEquals($tb,
|
|
125
|
+
$this->assertNotEquals($tb, null);
|
|
126
126
|
$tb->clearBuffer();
|
|
127
127
|
$tb->setFV(FDN_ID, 1);
|
|
128
128
|
$tb->setFV(FDN_NAME, '小坂');
|
|
@@ -142,7 +142,7 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
142
142
|
private function getEqual($db, $tablename)
|
|
143
143
|
{
|
|
144
144
|
$tb = $this->openTable($db, $tablename);
|
|
145
|
-
$this->assertNotEquals($tb,
|
|
145
|
+
$this->assertNotEquals($tb, null);
|
|
146
146
|
$tb->clearBuffer();
|
|
147
147
|
$tb->setFV(FDN_ID, 1);
|
|
148
148
|
$tb->seek();
|
|
@@ -151,12 +151,12 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
151
151
|
private function find($db, $tablename)
|
|
152
152
|
{
|
|
153
153
|
$tb = $this->openTable($db, $tablename);
|
|
154
|
-
$this->assertNotEquals($tb,
|
|
154
|
+
$this->assertNotEquals($tb, null);
|
|
155
155
|
$tb->setKeyNum(0);
|
|
156
156
|
$tb->clearBuffer();
|
|
157
157
|
$tb->setFilter('番号 >= 1 and 番号 < 3', 1, 0);
|
|
158
158
|
$tb->setFV(FDN_ID, 1);
|
|
159
|
-
$tb->find(
|
|
159
|
+
$tb->find(Table::findForword);
|
|
160
160
|
$this->assertEquals($tb->stat(), 0);
|
|
161
161
|
$this->assertEquals($tb->getFVint(FDN_ID), 1);
|
|
162
162
|
$this->assertEquals($tb->getFVstr(FDN_NAME), '小坂');
|
|
@@ -165,7 +165,7 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
165
165
|
$this->assertEquals($tb->getFVint(FDN_ID), 2);
|
|
166
166
|
$this->assertEquals($tb->getFVstr(FDN_NAME), '矢口');
|
|
167
167
|
$tb->findNext(true);
|
|
168
|
-
$this->assertEquals($tb->stat(),
|
|
168
|
+
$this->assertEquals($tb->stat(), Transactd::STATUS_EOF);
|
|
169
169
|
}
|
|
170
170
|
private function doWhole($db, $tableid, $tablename, $url)
|
|
171
171
|
{
|
|
@@ -180,37 +180,37 @@ class transactdKanjiSchemaTest extends PHPUnit_Framework_TestCase
|
|
|
180
180
|
|
|
181
181
|
public function testCreateDatabase()
|
|
182
182
|
{
|
|
183
|
-
$db = new
|
|
183
|
+
$db = new Database();
|
|
184
184
|
$this->createDatabase($db, URL);
|
|
185
185
|
}
|
|
186
186
|
public function testTableWhichHasKanjiNamedField()
|
|
187
187
|
{
|
|
188
|
-
$db = new
|
|
188
|
+
$db = new Database();
|
|
189
189
|
$this->doWhole($db, 1, 'kanji-field', URL);
|
|
190
190
|
}
|
|
191
191
|
public function testKanjiNamedTable()
|
|
192
192
|
{
|
|
193
|
-
$db = new
|
|
193
|
+
$db = new Database();
|
|
194
194
|
$this->doWhole($db, 2, '漢字テーブル', URL);
|
|
195
195
|
}
|
|
196
196
|
public function testCreateKanjiNamedDatabase()
|
|
197
197
|
{
|
|
198
|
-
$db = new
|
|
198
|
+
$db = new Database();
|
|
199
199
|
$this->createDatabase($db, URL_KANJI); // URL must be UTF-8
|
|
200
200
|
}
|
|
201
201
|
public function testTableWhichHasKanjiNamedFieldInKanjiNamedDatabase()
|
|
202
202
|
{
|
|
203
|
-
$db = new
|
|
203
|
+
$db = new Database();
|
|
204
204
|
$this->doWhole($db, 1, 'kanji-field', URL_KANJI);
|
|
205
205
|
}
|
|
206
206
|
public function testKanjiNamedTableInKanjiNamedDatabase()
|
|
207
207
|
{
|
|
208
|
-
$db = new
|
|
208
|
+
$db = new Database();
|
|
209
209
|
$this->doWhole($db, 2, '漢字テーブル', URL_KANJI);
|
|
210
210
|
}
|
|
211
211
|
public function testDropDatabase()
|
|
212
212
|
{
|
|
213
|
-
$db = new
|
|
213
|
+
$db = new Database();
|
|
214
214
|
$this->dropDatabase($db, URL_KANJI);
|
|
215
215
|
}
|
|
216
216
|
}
|