Adamhumbug Posted June 19, 2022 Share Posted June 19, 2022 Hi all, I have a function that is returning data from a select statement. I am wanting to change the fields that are returned dynamically based on a variable that is passed into the function. I thought i would be able to do this with a switch and a variable name in the select statement. I have done some reading and it seems that this is not a thing that can be done. Would the best option be to get all fields that i might want to decide which to use after the data has been returned? Quote Link to comment https://forums.phpfreaks.com/topic/314940-define-fields-to-be-returned-with-pdo-variables/ Share on other sites More sharing options...
mac_gyver Posted June 19, 2022 Share Posted June 19, 2022 of course you can do this, by supplying an array of the column names as an input to the function, then dynamically building the select list (see php's implode() function). Quote Link to comment https://forums.phpfreaks.com/topic/314940-define-fields-to-be-returned-with-pdo-variables/#findComment-1597450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.