note 125657 added to pdostatement.bindcolumn

From: Date: Tue, 05 Jan 2021 17:34:01 +0000
Subject: note 125657 added to pdostatement.bindcolumn
Groups: php.notes 
Request: Send a blank email to php-notes+get-216065@lists.php.net to get a copy of this message
I wanted to efficiently bind columns and then put everything into one array. <?php $columns = array( 'DEVICE_CONFIG' => '', 'CONSUMABLE_INFO' => '', 'DEVICE_UNIQUE_ID' => '', 'STATUS' => '', 'STATUS_MESSAGE' => '', 'LAST_MESSAGE_TIME' => '', 'DEVICE_DESCRIPTION' => '' ); $statement = $this->connection->prepare($sql); $statement->execute(); $x = 1; foreach($columns as $column => $index){ $$column = $index; eval('$statement->bindColumn(' . $x++ . ', $' . $column . ');'); } $output= array(); while($statement->fetch(\PDO::FETCH_BOUND)){ $temp = array(); foreach($columns as $columnName => $val){ eval("\$data = \$$columnName;"); $temp[$columnName] = $data; } $output[] = $temp; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 195.138.250.34 (proxied: 2603:4010:5c00::10) ---- Manual Page -- http://php.net/manual/en/pdostatement.bindcolumn.php Edit -- https://master.php.net/note/edit/125657 Del: integrated -- https://master.php.net/note/delete/125657/integrated Del: useless -- https://master.php.net/note/delete/125657/useless Del: bad code -- https://master.php.net/note/delete/125657/bad+code Del: spam -- https://master.php.net/note/delete/125657/spam Del: non-english -- https://master.php.net/note/delete/125657/non-english Del: in docs -- https://master.php.net/note/delete/125657/in+docs Del: other reasons-- https://master.php.net/note/delete/125657 Reject -- https://master.php.net/note/reject/125657 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#216065) next »