Comments (7)
Hi, are you passing an array of values? queue()
expects the values directly:
$inserter->queue(7, 'DDWWWB', NULL, ...);
and not:
$inserter->queue([7, 'DDWWWB', NULL, ...]);
from db.
Hi, my var_dump echos this:
string(117) "7,'4B1616',NULL,'SWR1310',51.764226,12.048035,36975,-64,42,406,'2019-04-29','2019-04-29 10:17:01.900000',1556525821.9"
The manual version is:
$inserter->queue(7,'4B1616',NULL,'SWR1310',51.764226,12.048035,36975,-64,42,406,'2019-04-29','2019-04-29 10:17:01.900000',1556525821.9);
which works fine...
from db.
In the first case you're passing the arguments as a string, which is obviously a single argument.
Where is your data coming from?
from db.
Hi, i´m prasing an JSON String.
from db.
Please share the code!
from db.
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();
from db.
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
from db.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from db.