16 if ($this->_mysqli->connect_error) {
17 return $this->_mysqli->connect_error;
19 $this->_mysqli->set_charset(
'utf8');
20 $this->_mysqli->autocommit(FALSE);
21 mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
28 $this->_mysqli->close();
32 $this->_mysqli->begin_transaction();
36 $this->_mysqli->commit();
40 $this->_mysqli->rollback();
43 public function esc($str) {
44 return $this->_mysqli->real_escape_string($str);
48 return $this->_mysqli->query($sql);
52 return $this->_mysqli->insert_id;
59 if ($result = $this->_mysqli->query($sql)) {
60 while ($row = $result->fetch_assoc()) {
72 $last = (
$cnt - $mod) / $rpp;
86 $ofst = ($page - 1) * $rpp;
102 .
" `id`, `name`, `disp_name`, `term_year`, `term_begin`, `term_end`"
104 .
" WHERE `id` = '" . $this->
esc($bid) .
"'"
109 if (empty($rec[0])) {
113 $rec[0][
'era'] = $this->
era($bid, $rec[0][
'term_begin']);
121 case 'c_c0':
return $this->
_getC0();
break;
122 case 'c_c1':
return $this->
_getC1();
break;
123 case 'c_c2':
return $this->
_getC2();
break;
124 case 'c_c3':
return $this->
_getC3();
break;
125 case 'c_c4':
return $this->
_getC4();
break;
126 case 'c_deb_cre':
return $this->
_getDebCre();
break;
128 case 'c_round':
return $this->_getRount();
break;
129 case 'c_settled':
return $this->
_getSettled();
break;
138 $sql =
"SELECT * FROM `c_c0` ORDER BY `c0`";
143 foreach ($rec as $r) {
144 $ans[$r[
'c0']] = $r[
'name'];
153 $sql =
"SELECT * FROM `c_c1` ORDER BY `c1`";
158 foreach ($rec as $r) {
159 $ans[$r[
'c1']] = $r[
'name'];
168 $sql =
"SELECT * FROM `c_c2` ORDER BY `c1`, `c2`";
173 foreach ($rec as $r) {
174 $ans[$r[
'c1']][$r[
'c2']] = $r[
'name'];
183 $sql =
"SELECT * FROM `c_c3` ORDER BY `c1`, `c2`, `c3`, `div`";
188 foreach ($rec as $r) {
189 $ans[$r[
'c1']][$r[
'c2']][$r[
'c3']] = [
'div' => $r[
'div'],
'name' => $r[
'name']];
198 $sql =
"SELECT * FROM `c_c4` ORDER BY `c1`, `c2`, `c3`, `c4`";
203 foreach ($rec as $r) {
204 $ans[$r[
'c1']][$r[
'c2']][$r[
'c3']][$r[
'c4']] = $r[
'name'];
213 $sql =
"SELECT * FROM `c_deb_cre` ORDER BY `c0`";
218 foreach ($rec as $r) {
219 $ans[$r[
'c0']] = [
'abbr' => $r[
'abbr'],
'name' => $r[
'name']];
228 $sql =
"SELECT * FROM `c_item_class` ORDER BY `c0`";
233 foreach ($rec as $r) {
234 $ans[$r[
'c0']] = $r[
'name'];
243 $sql =
"SELECT * FROM `c_round` ORDER BY `c0`";
248 foreach ($rec as $r) {
249 $ans[$r[
'c0']] = $r[
'name'];
258 $sql =
"SELECT * FROM `c_settled` ORDER BY `c0`";
263 foreach ($rec as $r) {
264 $ans[$r[
'c0']] = $r[
'name'];
275 .
" `t0`.`ctg`" .
" AS " .
"`ctg`"
276 .
", `t3`.`div`" .
" AS " .
"`div`"
277 .
", `t0`.`name`" .
" AS " .
"`name`"
280 .
"SELECT `c1`, `c2`, `c3`, `c1` * 1000 + `c2` * 100 + `c3` * 10 AS `ctg`, `name`"
283 .
" SELECT `c1`, `c2`, `c3`, `c1` * 1000 + `c2` * 100 + `c3` * 10 + `c4` AS `ctg`, `name`"
286 .
" INNER JOIN `c_c3` `t3` ON `t0`.`c1` = `t3`.`c1` AND `t0`.`c2` = `t3`.`c2` AND `t0`.`c3` = `t3`.`c3`"
287 .
" ORDER BY `t0`.`ctg`"
294 foreach ($rec as $r) {
295 $ans[$r[
'ctg']] = [
'div' => $r[
'div'],
'name' => $r[
'name']];
305 $sql =
"SELECT `ccd`, `item`, `name`"
306 .
" FROM `t_account`"
307 .
" WHERE `bid` = '" . $this->
esc($bid) .
"'"
308 .
" ORDER BY `ccd`, `item`"
315 foreach ($rec as $r) {
316 $ans[$r[
'ccd']][$r[
'item']] = $r[
'name'];
326 $sql =
"SELECT `ccd`, `item`, `name`"
327 .
" FROM `t_account`"
328 .
" WHERE `bid` = '" . $this->
esc($bid) .
"'"
330 .
" ORDER BY `ccd`, `item`"
337 foreach ($rec as $r) {
338 $ans[$r[
'ccd'] * 100 + $r[
'item']] = $r[
'name'];
348 $sql =
"SELECT `kcd`, `name`, `kana`"
350 .
" WHERE `bid` = '" . $this->
esc($bid) .
"'"
358 foreach ($rec as $r) {
359 $ans[$r[
'kcd']] = [
'name' => $r[
'name'],
'kana' => $r[
'kana']];
369 $sql =
"SELECT `kcd`, `name`, `kana`"
371 .
" WHERE `valid_flg` = TRUE AND `bid` = '" . $this->
esc($bid) .
"'"
379 foreach ($rec as $r) {
380 $ans[$r[
'kcd']] = [
'name' => $r[
'name'],
'kana' => $r[
'kana']];
390 $sql =
"SELECT `kcd`, `name`"
392 .
" WHERE `valid_flg` = TRUE AND `bid` = '" . $this->
esc($bid) .
"'"
393 .
" ORDER BY `update_time` DESC, `kana` ASC"
400 foreach ($rec as $r) {
401 $ans[$r[
'kcd']] = $r[
'name'];
416 $sql =
"UPDATE `t_item` SET"
417 .
" `dummy` = '" . date(
'YmdHis') .
"'"
418 .
" WHERE `id` = '" . $this->
esc($id) .
"'"
420 $ans = $this->
query($sql);
422 }
catch(Exception $e) {
423 $err = $e->getMessage();
441 $sql =
"SELECT `id`, `name`"
442 .
" FROM `t_section`"
443 .
" WHERE `bid` = '" . $this->
esc($bid) .
"'"
451 foreach ($rec as $r) {
452 $ans[$r[
'id']] = $r[
'name'];
459 $s = str_replace(
"_",
"\\_", $s);
460 $s = str_replace(
"$",
"\\$", $s);
464 public function era($bid, $day)
467 $sql =
"SELECT `ymd`, `era`, `abr` FROM `t_era` WHERE `bid` = " . $this->
esc($bid) .
" ORDER BY `ymd`";
473 $era[$n++] = [
'??',
'?',
'0000-00-00'];
474 foreach ($rec as $r) {
475 $era[$n++] = [$r[
'era'], $r[
'abr'], $r[
'ymd']];
478 for ($i = 0; $i < $n; $i++) {
479 if ($day >= $era[$i][2]) {
484 $ymd = explode(
'-', $day);
485 $a = explode(
'-', $chk[2]);
486 $nen = $ymd[0] - $a[0] + 1;
488 $ans[
"name"] = $chk[0] . $nen;
489 $ans[
"abbr"] = $chk[1] . $nen;
497 $sql =
"SELECT COUNT(*) AS `cnt` FROM `t_journal` WHERE `bid` = " . $this->
esc($bid);
501 return $rec[0][
'cnt'];