| @@ 1055-1085 (lines=31) @@ | ||
| 1052 | ||
| 1053 | // Do batch update or insert, prepare stmt first |
|
| 1054 | $sql = ''; |
|
| 1055 | if ('U' == $mode) { |
|
| 1056 | $ar_conf = array( |
|
| 1057 | 'UPDATE' => $tbl, |
|
| 1058 | 'LIMIT' => 1, |
|
| 1059 | ); |
|
| 1060 | foreach ($pk as $key) { |
|
| 1061 | // Primary key need remove from 'SET' clause |
|
| 1062 | // Actual value will assign later, do quote then. |
|
| 1063 | // :NOTICE: Remember to put pk data to end of row data when assign, |
|
| 1064 | // because where clause is after set clause. |
|
| 1065 | $ar_conf['WHERE'][] = "$key = " |
|
| 1066 | . $this->Param($key); |
|
| 1067 | unset($ar_cols[array_search($key, $ar_cols)]); |
|
| 1068 | } |
|
| 1069 | // Convert array $ar_cols with to prepare param |
|
| 1070 | $ar_set = array(); |
|
| 1071 | foreach ($ar_cols as $key) |
|
| 1072 | $ar_set[$key] = $this->Param($key); |
|
| 1073 | // Fin, assign 'SET' clause |
|
| 1074 | $ar_conf['SET'] = $ar_set; |
|
| 1075 | } |
|
| 1076 | elseif ('I' == $mode) { |
|
| 1077 | $ar_set = array(); |
|
| 1078 | foreach ($ar_cols as $key) { |
|
| 1079 | $ar_set[$key] = $this->Param($key); |
|
| 1080 | } |
|
| 1081 | $ar_conf = array( |
|
| 1082 | 'INSERT' => $tbl, |
|
| 1083 | 'VALUES' => $ar_set, |
|
| 1084 | ); |
|
| 1085 | } |
|
| 1086 | $sql = $this->GenSqlPrepare($ar_conf); |
|
| 1087 | ||
| 1088 | /* Treat moved to SqlGenerator |
|
| @@ 1483-1511 (lines=29) @@ | ||
| 1480 | } |
|
| 1481 | ||
| 1482 | // Prepare sql |
|
| 1483 | if ('U' == $mode) { |
|
| 1484 | $sqlCfg = [ |
|
| 1485 | 'UPDATE' => $table, |
|
| 1486 | 'LIMIT' => 1, |
|
| 1487 | ]; |
|
| 1488 | // Primary key cannot change, so exclude them from SET clause, |
|
| 1489 | // Here use prepare, actual value will assign later, do quote |
|
| 1490 | // then. |
|
| 1491 | // :NOTICE: Remember to put PK data to end of row data array when |
|
| 1492 | // assign actual value, because WHERE clause is after SET clause. |
|
| 1493 | foreach ($arPk as $key) { |
|
| 1494 | $sqlCfg['WHERE'][] = "$key = " |
|
| 1495 | . $this->pdoParam($table, $key); |
|
| 1496 | unset($arCols[array_search($key, $arCols)]); |
|
| 1497 | } |
|
| 1498 | foreach ($arCols as $key) { |
|
| 1499 | $sqlCfg['SET'][$key] = $this->pdoParam($table, $key); |
|
| 1500 | } |
|
| 1501 | ||
| 1502 | } elseif ('I' == $mode) { |
|
| 1503 | $arVal = []; |
|
| 1504 | foreach ($arCols as $key) { |
|
| 1505 | $arVal[$key] = $this->pdoParam($table, $key); |
|
| 1506 | } |
|
| 1507 | $sqlCfg = [ |
|
| 1508 | 'INSERT' => $table, |
|
| 1509 | 'VALUES' => $arVal, |
|
| 1510 | ]; |
|
| 1511 | } |
|
| 1512 | $sql = $this->getSqlGenerator()->getPrepared($sqlCfg); |
|
| 1513 | // @codeCoverageIgnoreStart |
|
| 1514 | if (empty($sql)) { |
|