-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught InvalidArgumentException: The number of values (1) does not match the field count (13). #4
Comments
Hi, are you passing an array of values? $inserter->queue(7, 'DDWWWB', NULL, ...); and not: $inserter->queue([7, 'DDWWWB', NULL, ...]); |
Hi, my var_dump echos this:
The manual version is:
|
In the first case you're passing the arguments as a string, which is obviously a single argument. |
Hi, i´m prasing an JSON String. |
Please share the code! |
Hello Ben, my approach to build a $ values variable was not necessary at all. I realized that I can simply feed the values into the function. Here is my working code example: $inserter = new BulkInserter($pdo, 'flights_tmp', ['source', 'hex', 'squawk', 'callsign', 'altitude']);
foreach ($row_outer[$x] as $row) {
// hex: the 24-bit ICAO identifier of the aircraft, as 6 hex digits.
// The identifier may start with '~', this means that the address is a non-ICAO address (e.g. from TIS-B).
if(isset($row['hex'])) {
$hex = strtoupper(trim($row['hex']));
}else $hex = NULL;
// squawk: the 4-digit squawk (octal representation)
if(isset($row['squawk'])) {
$squawk = intval($row['squawk']);
}else $squawk = NULL;
// flight: the flight name / callsign
if(isset($row['flight'])) {
$flight = strtoupper(trim($row['flight']));
}else $flight = '?';
// lat, lon: the aircraft position in decimal degrees
if(isset($row['lat'])) {
$latitude = floatval($row['lat']);
}else $latitude = NULL;
// lat, lon: the aircraft position in decimal degrees
if(isset($row['lon'])) {
$longitude = floatval($row['lon']);
}else $longitude = NULL;
$inserter->queue($source, $hex, $squawk, $squawk, $flight, $altitude);
}
$inserter->flush(); |
Hi, exactly. If you're passing an array, it's considered a single argument hence the argument count does not match. Alternatively, you can unpack an array this way: $values = [$source, $hex, $squawk, $squawk, $flight, $altitude];
$inserter->queue(...$values); // unpacking the array into multiple arguments |
Hallo,
first, thank you for this cool piece of software. It woks well for me when filling the $inserter->queue() manually, but i get this error when using data from a variable $inserter->queue($values).
My $values contains 7,'DDWWWB',NULL,'SWR',51.26,12.35,36975,-64,42,406,'2019-04-29','2019-04-29 10:17:01.900',1556525821.9
Any hint for me?
The text was updated successfully, but these errors were encountered: