method getInsert documentation in bbn\Db\Languages\Pgsql

Generates a string for the insert from a cfg array.

function(array $cfg) { $fields_to_put = [ 'values' => [], 'fields' => [], ]; $i = 0; foreach ($cfg['fields'] as $alias => $f) { if (isset($cfg['available_fields'][$f], $cfg['models'][$cfg['available_fields'][$f]])) { $model = $cfg['models'][$cfg['available_fields'][$f]]; $csn = $this->colSimpleName($f); $is_uid = false; //X::hdump('---------------', $idx, $f, $tables[$idx]['model']['fields'][$csn], $args['values'], // $res['values'], '---------------'); if (isset($model['fields'][$csn])) { $column = $model['fields'][$csn]; if (($column['type'] === 'binary') && ($column['maxlength'] === 16)) { $is_uid = true; } $fields_to_put['fields'][] = $this->colSimpleName($f, true); $fields_to_put['values'][] = '?'; } } else { $this->error("Error! The column '$f' doesn't exist in '" . implode(', ', $cfg['tables'])); } $i++; } if (count($fields_to_put['fields']) && (count($cfg['tables']) === 1)) { return 'INSERT INTO ' . $this->tableFullName(current($cfg['tables']), true) . PHP_EOL . '(' . implode(', ', $fields_to_put['fields']) . ')' . PHP_EOL . ' VALUES (' . implode(', ', $fields_to_put['values']) . ')' . PHP_EOL . (!empty($cfg['ignore']) ? ' ON CONFLICT DO NOTHING' : '') . PHP_EOL; } return ''; }

Generates a string for the insert from a cfg array. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.