NogDog;11014487 wrote:I'll just point out here that it's possible to tell json_decode() to return everything as arrays
D'oh! I forgot about that option (probably because I don't use JSON much at all).
@: You might want to check out that option; see the manual page for [man]json_decode/man for more info/examples.
XMLnewbi;11014491 wrote:something like
INSERT INTO Deposits
VALUES ($address_info->txs[0]->inputs[0]->prev_out->value, value2, value3,...)
My point was that that if this:
$address_info->txs[0]->inputs[0]->prev_out->value
contains a string value, you can use it in the same way you could use a literal string:
"foobar"
The only potential difference might be in the syntax you use. For example, with such a long chain as in your example, I would either use string concatenation or [man]sprintf/man.
However, since we're talking about SQL queries, it would probably be even easier (since you are propertly sanitizing all your data as well, right?? 🙂) to just use a parameterized query since the code would be a lot cleaner, e.g.:
// skeleton example; lots of error checking/handling is missing
// connect to db
$mysqli = new mysqli( "example.com", "user", "password", "database" );
// prepare the query
$stmt = $mysqli->prepare( 'INSERT INTO Deposits (int_column, double_column, varchar_column) VALUES (?, ?, ?)' );
// bind the three values
$stmt->bind_param( "i", 123456 );
$stmt->bind_param( "d", 123.456 );
$stmt->bind_param( "s", $obj->with[4]->layers->of->properties );
// execute the query
$stmt->execute();