mysql_field_count(3)
💖 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 bymysql_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
- alpine 3.22: mariadb-doc 11.4.13-r0 · GPL-2.0-or-later
- alpine 3.23: mariadb-doc 11.4.13-r0 · GPL-2.0-or-later
- alpine 3.24: mariadb-doc 11.8.9-r0 · GPL-2.0-only
- arch rolling: mariadb 13.0.2-2 · GPL-2.0-only
- arch rolling: mariadb-lts 12.3.3-2 · GPL-2.0-only
- centos-stream 10: mariadb-connector-c-doc 3.4.4-2.el10 · LGPL-2.1-or-later
- debian trixie: libmariadb-dev 1:11.8.6-0+deb13u1 · GPL-2.0-only
- fedora 43: mariadb-connector-c-doc 3.4.5-2.fc43 · LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 43: mariadb-connector-c-doc 3.4.9-2.fc43 · LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- fedora 44: mariadb-connector-c-doc 3.4.8-3.fc44 · LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01
- fedora 44: mariadb-connector-c-doc 3.4.9-2.fc44 · LGPL-2.1-or-later AND PHP-3.0 AND PHP-3.01 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: mariadb-server 11.8.8
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 · LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 · LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 · LGPL-2.1-or-later
- opensuse-leap 16.0: libmariadb-devel 3.4.9-160000.1.1 · LGPL-2.1-or-later
- ubuntu questing: libmariadb-dev 1:11.8.3-1build1
- ubuntu resolute: libmariadb-dev 1:11.8.6-5 · GPL-2.0-only
- ubuntu resolute: libmariadb-dev 1:11.8.6-5ubuntu0.1 · GPL-2.0-only
- ubuntu stonking: libmariadb-dev 1:11.8.9+ds-4ubuntu2 · GPL-2.0-only
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms