I have this situation with PHP (PDO);
I\'m implementing a method that retrieves data from MySql and does it well, but the problem is that duplicate data recovered as
By default PDO uses the PDO::FETCH_BOTH as its fetch result. Meaning that it maps every column to its name and to an 'integer' column name.
Check the fetch_style param= http://php.net/manual/en/pdostatement.fetch.php
For your expected result you will need to use the PDO::FETCH_ASSOC
attribute.
You can or set this as the default FETCH_MODE on the pdo object as follows:
$this->db->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
Or you can specify it for every fetch cal:
$value = $statement->fetchAll(PDO::FETCH_ASSOC);
change pdo attribute accoding to requirment. . .
$dbConnection = new PDO( 'pgsql:host=' . $host . ';dbname=' . $database, $username,
$password, );
$dbConnection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
set / change PDO attribute more detail here