I am querying a psql database through PHP to get an array of boolean values where indexes are userids, e.g. userconfirm bool[]. When I do something like:
$query = "select userconfirm from calendar where id = '%s'";
$result = $this->db->query($query, 2);
var_dump($result['userconfirm']);
I get:
array(1) { [0]=> array(1) { ["userconfirm"]=> string(20) "[256:258]={t,NULL,t}" } }
Which is to say I get a string where the array should be. Ok, parsing this could probably be done, if I studied up on PHP, but this feels wrong. Surely there’s a way to get the array directly?
Main question is: How do I get this array to PHP directly?
Secondary question: Is this a suitable format for keeping track of user attendance? Is there a better way?
(Re-posted from a comment by request)
Glancing at the documentation, it doesn’t appear as though there’s a way to directly interpolate a PostgreSQL array to an array in PHP. However, if the position of your vector represents a user id, you might be better off restructuring your data to columns with
user_idandattended(the latter of which should be abooleandatatype).