mysql_field_count(3)

📦
version 13.0.2 · 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

💖 mysql_field_count(3) 💖

okay bestie, so this one is from the MariaDB Connector/C manual and honestly? it's a tiny little legend. we're talking mysql_field_count(3) — the function that tells you how many columns your most recent statement was serving up. 🎀


✨ Name ✨

mysql_field_count — returns the number of columns for the most recent statement 💅


✨ Synopsis ✨

#include <mysql.h>

unsigned int mysql_field_count(MYSQL * mysql);

look at that. one line, zero drama, unsigned int return type. we love a low-maintenance icon. 🦋


✨ Description ✨

So here's the tea, bestie: mysql_field_count() hands you back the number of columns for the most recent statement on the connection represented by the link parameter, and it gives it to you as an unsigned int. 🫶

And like… where does it actually pop off? When you're out here using mysql_store_result(3) and you need to figure out whether the query should have produced a non-empty result set or not — without knowing the nature of the query. That's the moment. That's its main character moment. 👑


✨ Parameters ✨

  • mysql — this is a connection identifier. and not just any connection identifier: it's one that was previously allocated by mysql_init(3) and then connected by mysql_real_connect(3). so like, don't just roll up with a random pointer, okay? it's giving ✨established connection✨ or it's giving nothing. 🌸

✨ Notes ✨

real talk: mysql_field_count() is the function you should be using to determine if there is a result set available. that's literally its job. let it cook. 🍓

✨ Return value: ✨

It returns the number of columns for the most recent statement. 💖

And if the statement didn't produce a result set? The value is zero. 😭 that's it. zero. nothing. no columns, no vibes. but at least now you know fr fr.


✨ See also ✨

go read those too, bestie, they're literally the whole reason this function exists. iykyk. 💜


and that's the whole page!! this was Version 3.4 of the MariaDB Connector/C docs, mysql_field_count(3), and yeah — she's short, she's sweet, she ate and left no crumbs. mwah. 💅✨🎀

📦 where this page comes from