mysql_query(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

πŸŽ€ NAME πŸŽ€

mysql_query β€” she executes a null terminated statement string for you, and she does it flawlessly πŸ’…

this page is filed in the MariaDB Connector/C manual, section 3, and it's all about the one and only mysql_query(3).


✨ SYNOPSIS ✨

#include <mysql.h>

int mysql_query(MYSQL * mysql,
                const char * query);

πŸ’– DESCRIPTION πŸ’–

okay so mysql_query() takes the statement pointed to by the null terminated string query and performs it against the database. that's the whole job. she ate, no crumbs πŸ”₯

but the one thing you HAVE to know, bestie: contrary to mysql_real_query(3), mysql_query() is not binary safe. if your data is spicy binary nonsense, do not bring it here 😭


🌸 PARAMETER 🌸

  • mysql β€” a mysql handle, and she has to have been previously allocated by mysql_init(3) and connected by mysql_real_connect(3). otherwise it's giving chaos, not results 🫠
  • query β€” a null terminated string containing the statement to be performed. that's your whole vibe right there ✨
tiny side note from me to you: this function takes literally no flags at all. not -a, not anything else β€” just these two arguments and vibes, iykyk πŸŽ€

πŸ¦‹ NOTES πŸ¦‹

  • for executing multi statements, the statements within that null terminated string must be separated by a semicolon (;). that's the entire trick, no cap πŸ“
  • if your statement contains binary data, you should use mysql_real_query(3) instead, or escape your data with mysql_hex_string(3). do one of those, fr fr πŸ™ˆ
  • to determine if a statement returned a result set, use mysql_field_count(3). she will tell you everything πŸ‘‘

⭐ RETURN VALUE ⭐

  • returns zero on success πŸ’–
  • returns non zero on failure πŸ’€

🌈 SEE ALSO 🌈


that's the whole page, bestie 🫢 this one comes from the MariaDB Connector/C manual, Version 3.4, and the title it's filed under is mysql_query(3). now go forth and may all your queries return zero πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from