Code example: MySQL to Aerospike


#1

Hi! I try to search but i not find nothing :frowning:

Is possible translate this code for aerospike?

$result = mysql_query("SELECT id, name FROM mytable");

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    printf("ID: %s  Name: %s", $row["id"], $row["name"]);
}

I try something but nothing, the cycle while is important for me, maybe this is good for some people

Thank!!!


#2

The main difference is that an old RDBMS like MySQL holds your results in memory on its side and you get a cursor to walk through that result set. You iterate through it when you get the results, and hopefully release it at the end. Aerospike does not dedicate server-side memory for your results, instead your connection is lightweight (consuming a file descriptor) and results from a scan or query are streamed to the client.

In the PHP client you attach a callback function to the scan or query to handle each incoming record from the server. There is also sample code in the quick guide for scan and query.