yiisoft / yiisoft/db

How to set a PDO statement attribute?

Open
#65 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:enhancement
Dominant language
PHP
Stars
216
Forks
51
Avg merge
3d 10h
Merged PRs (30d)
2

Description

I have to use the each method to select in batches. The problem is, that I have to delete some columns in this foreach, which generates a table lock. Now I have to set the cursor PDO::ATTR_CURSOR to forward only PDO::CURSOR_FWDONLY. Is this even possible by now?

$simpleQuery = SimpleObject::find();
// need something like: $simpleQuery->setPdoStmtAttr(\PDO::ATTR_CURSOR, \PDO::CURSOR_FWDONLY);
foreach ($simpleQuery->each() as $simpleObject) {
    // fancy things...
}

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 at the SimpleObject::find() entry point and follow each() to where its PDO statement is created or configured. Determine how a caller could request PDO::ATTR_CURSOR with PDO::CURSOR_FWDONLY, then verify the behavior while iterating and deleting records in batches.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.