static PyObject* wsql_result_fetch_row_async(wsql_result *self) { PyObject *row = NULL, *result = NULL; MYSQL_ROW mysql_row; net_async_status status; CHECK_RESULT(self, NULL); status = mysql_fetch_row_nonblocking(self->result, &mysql_row); if (status == NET_ASYNC_NOT_READY) { row = Py_None; Py_INCREF(row); } else { row = wsql_result_convert_row(self, mysql_row); } if (row) { result = Py_BuildValue("(iO)", status, row); Py_DECREF(row); return result; } return NULL; }
static Variant HHVM_FUNCTION(mysql_async_fetch_array, const Resource& result, int result_type /* = 1 */) { if ((result_type & PHP_MYSQL_BOTH) == 0) { throw_invalid_argument("result_type: %d", result_type); return false; } auto res = php_mysql_extract_result(result); if (!res) { return false; } MYSQL_RES* mysql_result = res->get(); if (!mysql_result) { raise_warning("invalid parameter to mysql_async_fetch_array"); return false; } MYSQL_ROW mysql_row = nullptr; int status = mysql_fetch_row_nonblocking(mysql_result, &mysql_row); // Last row, or no row yet available. if (status != NET_ASYNC_COMPLETE) { return false; } if (mysql_row == nullptr) { res->close(); return false; } unsigned long *mysql_row_lengths = mysql_fetch_lengths(mysql_result); if (!mysql_row_lengths) { return false; } mysql_field_seek(mysql_result, 0); Array ret; MYSQL_FIELD *mysql_field; int i; for (mysql_field = mysql_fetch_field(mysql_result), i = 0; mysql_field; mysql_field = mysql_fetch_field(mysql_result), i++) { Variant data; if (mysql_row[i]) { data = mysql_makevalue(String(mysql_row[i], mysql_row_lengths[i], CopyString), mysql_field); } if (result_type & PHP_MYSQL_NUM) { ret.set(i, data); } if (result_type & PHP_MYSQL_ASSOC) { ret.set(String(mysql_field->name, CopyString), data); } } return ret; }