cakephp / cakephp/phinx

The fetch_style used when fetching rows is not amendable.

Open
#450 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement waiting on feedback
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

For me, I would normally use PDO::FETCH_ASSOC, but currently it is PDO::FETCH_BOTH which results in the result containing both numeric and associative indices.

I'm happy to do the work on this, but would like some suggestions on what a suitable solution would be.

Mine would be to add a new element to the PdoAdapter::$options array called (maybe) default_fetch_style with a default value of the current default value of PDO::FETCH_BOTH.

The default could be overridden by a new PdoAdapter:::setOption($option, $value) method which would set a single option. It would validate the value if the option is default_fetch_style and throw an exception if an inappropriate value is supplied.

Each call to any method in the PdoAdapter that is currently using the default of PDO::FETCH_BOTH would be switched to use PdoAdapater::getOption('default_fetch_style').

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting PdoAdapter and locating each row-fetching call that currently relies on PDO::FETCH_BOTH. Review the proposed option and setter approach, then confirm that the default remains unchanged while callers can select PDO::FETCH_ASSOC and invalid styles are rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.