⇧
vadnica-logo
My Services About the Project Telegram O meni O meni

Retrieving a Value with the fetchColumn() Method

The fetchColumn() method returns a single column value from the next row of a result set. If you do not specify the column, it defaults to returning the first column (index 0). This method is extremely convenient when executing queries that return only a single piece of data, such as counting records (COUNT) or fetching a specific field for an individual user.

EXAMPLE
RESULT
The result will be displayed here...

Practical Application: We use the fetchColumn method when we want to shorten the code and avoid working with associative arrays, as we obtain the raw value (string or number) directly. Check the process at home by following these steps: