library/src/databases/bpdb/BP-DBSQLSyntaxGenerators.cc
// Fetches a result, results are automatically destroyed on fetch so be careful
// to copy data rather than reference it directly.
Fetches a result, results are automatically destroyed on fetch so be careful
to copy data rather than reference it directly.
Fetches a result results are automatically destroyed on fetch so be careful to copy data rather than reference it directly .
BP_ERROR_T BP_DBSGFetchResult
(
	P_BPDB_SQLGEN        syngen,
	P_BPDB_SQLGEN_SELECT select_info,
	BP_BOOL              create_json_reg
)
{
	if(!syngen)
		return ERR_FAILURE;
	if(!syngen->bpdb)
		return ERR_FAILURE;
	if(!select_info)
	{
		BP_DBAddErrorMsg(syngen->bpdb, "BP_DBSGFetchResult reports that it was run with a NULL select_info parameter.");
		return ERR_FAILURE;
	}
	if(!select_info->mariadb_stmt)
	{
		BP_DBAddErrorMsg(syngen->bpdb, "BP_DBSGFetchResult reports that it was run with a NULL select_info->mariadb_stmt parameter.");
		return ERR_FAILURE;
	}
	if(!select_info->bind_results)
	{
		BP_DBAddErrorMsg(syngen->bpdb, "BP_DBSGFetchResult reports that it was run with a NULL bind_results parameter.");
		return ERR_FAILURE;
	}
	if(BP_MySQLFetchResult(select_info->mariadb_stmt, syngen->mariadb) == ERR_SUCCESS)
	{
		select_info->fetched_record_n++;
		if(!select_info->fetched_record_hreg)
		{
			select_info->fetched_record_hreg = BP_CreateHashTableRegistry();
		}
		if(create_json_reg)
		{
			BP_DBSGUpdateJSONResultRegistry
			(
				syngen,
				select_info
			);
		}
		BP_MySQLFreeResult(select_info->mariadb_stmt, syngen->mariadb);
		return ERR_SUCCESS;
	}
	BP_MySQLFreeResult(select_info->mariadb_stmt, syngen->mariadb);
	return ERR_FAILURE;
}
BP_ERROR_T BP_DBSGFetchResult ( P_BPDB_SQLGEN syngen , P_BPDB_SQLGEN_SELECT select_info , BP_BOOL create_json_reg ) { if ( ! syngen ) return ERR_FAILURE ; if ( ! syngen -> bpdb ) return ERR_FAILURE ; if ( ! select_info ) { BP_DBAddErrorMsg ( syngen -> bpdb , " " ) ; return ERR_FAILURE ; } if ( ! select_info -> mariadb_stmt ) { BP_DBAddErrorMsg ( syngen -> bpdb , " " ) ; return ERR_FAILURE ; } if ( ! select_info -> bind_results ) { BP_DBAddErrorMsg ( syngen -> bpdb , " " ) ; return ERR_FAILURE ; } if ( BP_MySQLFetchResult ( select_info -> mariadb_stmt , syngen -> mariadb ) == ERR_SUCCESS ) { select_info -> fetched_record_n ++ ; if ( ! select_info -> fetched_record_hreg ) { select_info -> fetched_record_hreg = BP_CreateHashTableRegistry ( ) ; } if ( create_json_reg ) { BP_DBSGUpdateJSONResultRegistry ( syngen , select_info ) ; } BP_MySQLFreeResult ( select_info -> mariadb_stmt , syngen -> mariadb ) ; return ERR_SUCCESS ; } BP_MySQLFreeResult ( select_info -> mariadb_stmt , syngen -> mariadb ) ; return ERR_FAILURE ; }
Fetches a result, results are automatically destroyed on fetch so be careful
to copy data rather than reference it directly.
Fetches a result results are automatically destroyed on fetch so be careful to copy data rather than reference it directly .
// run basic null checks // ensure we have select_info // ensure we have a mariadb statement to process // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Retrieve Result if Possible %%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // fetch result // increment the record counter on successful fetch // create a new hash table registry if necessary // create new hash table registry // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Now Generate JSON Table For Values %%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // if we are creating a json reg, do it now // attempt to update the json result registry // destroy the result after fetching // return indicating success // destroy the result after fetching // return indicating failure