Closed ddb4github closed 5 years ago
Should be resolved.
Should be resolved.
After review my message. I found I make misleading between "Describe the bug" and "Expected behavior".
Actually, current function 'db_update_table' use 'array_diff' to compare PK. so sqltable_to_php.php
should always output a array if the latest line of output is db_update_table, like
db_update_table ('plugin_mikrotik_users', $data, false);
So suggest diff as below, base on ad50326:
--- sqltable_to_php.php 2019-05-25 19:42:53.000000000 +0800
+++ sqltable_to_php.php 2019-05-28 13:22:50.264353736 +0800
@@ -155,7 +155,7 @@
}
if (!empty($pri)) {
- if ($plugin != '' || !$create) {
+ if ($plugin != '' && $create) {
$text .= "\$data['primary'] = '" . implode("`,`", $pri) . "';\n";
} else {
$text .= "\$data['primary'] = array('" . implode("','", $pri) . "');\n";
Okay, fixed up.
Describe the bug db_update_table function does not support table data array that is generated by
sqltable_to_php.php
with args '--plugin' and '--update'$data['primary']
is always considered as array:$data['primary']
depend arg '--plugin'Expected behavior sqltable_to_php.php always output primary key as below if '--update' is specified:
$data['primary'] = 'host
,graph';