Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update use cases for the mode parameter in PDOStatement::fetchAll() #3549

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

colshrapnel
Copy link
Contributor

Currently, case 3 makes no sense (PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE would result in error) and case 4 is misleading (describing rather vanilla PDO::FETCH_GROUP's behavior). I added vanilla PDO::FETCH_UNIQUE and PDO::FETCH_GROUP cases and fixed PDO::FETCH_GROUP|PDO::FETCH_COLUMN.

Also, how does one remove a comment?

  • 88699 is bogus, they need PDO::FETCH_UNIQUE but using PDO::FETCH_GROUP
  • 122299 same as above
  • 115175 is bogus, PDO::FETCH_UNIQUE|PDO::FETCH_GROUP makes no sense and effectively just PDO::FETCH_UNIQUE

Currently, case 3 makes no sense ( PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE would result in error) and case 4 is misleading (describing rather vanilla PDO::FETCH_GROUP's behavior). I added vanilla  PDO::FETCH_UNIQUE and PDO::FETCH_GROUP cases and fixed PDO::FETCH_GROUP|PDO::FETCH_COLUMN.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the notes, and suggested some phrasing improvements. Please let me know if they are correct or not.

Comment on lines +57 to +60
To index the resulting array by certain column's value (instead of
consecutive numbers), put this column's name first in the column
list in SQL, and use <constant>PDO::FETCH_UNIQUE</constant>.
This column must contain only unique values or some data will be lost.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this reads better?

Suggested change
To index the resulting array by certain column's value (instead of
consecutive numbers), put this column's name first in the column
list in SQL, and use <constant>PDO::FETCH_UNIQUE</constant>.
This column must contain only unique values or some data will be lost.
To index the resulting array by a certain column's value (instead of
consecutive numbers), put this column's name first in the column
list in SQL, and use <constant>PDO::FETCH_UNIQUE</constant>.
This column must contain only unique values or some data will be lost.

Comment on lines +63 to +65
To group results in the form of 3-dimensional array indexed by values
of a specified column, put this column's name first in
the column list in SQL and use <constant>PDO::FETCH_GROUP</constant>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To group results in the form of 3-dimensional array indexed by values
of a specified column, put this column's name first in
the column list in SQL and use <constant>PDO::FETCH_GROUP</constant>.
To group results in the form of a 3-dimensional array indexed by values
of a specified column, put this column's name first in
the column list in SQL and use <constant>PDO::FETCH_GROUP</constant>.

Comment on lines +68 to +72
To group results in the form of 2-dimensional array (which indices will
be values of one column and values will be list arrays of values
from another column, list only these 2 columns in the column list in SQL
and use bitwise-OR <constant>PDO::FETCH_GROUP</constant> with
<constant>PDO::FETCH_COLUMN</constant>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To group results in the form of 2-dimensional array (which indices will
be values of one column and values will be list arrays of values
from another column, list only these 2 columns in the column list in SQL
and use bitwise-OR <constant>PDO::FETCH_GROUP</constant> with
<constant>PDO::FETCH_COLUMN</constant>.
To group results in the form of a 2-dimensional array, whose indices will
be the values of a column, and the associates values will be an array of values
from a second column.
Those 2 columns should be the only ones in the column list of the SQL,
and <parameter>mode</parameter> must be a bitwise-OR of
<constant>PDO::FETCH_GROUP</constant> with
<constant>PDO::FETCH_COLUMN</constant>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants