Questions tagged [unbuffered-queries]

20 questions
14
votes
3 answers

unbuffered query with MySQLi?

Are MySQLi queries unbuffered? If not, is there a way to do an unbuffered query, as with the non-MySQLi mysql_unbuffered_query()?
ceejayoz
  • 176,543
  • 40
  • 303
  • 368
13
votes
4 answers

What is causing PDO error Cannot execute queries while other unbuffered queries are active?

I have the following code: $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $dbh->setAttribute(PDO::ATTR_ERRMODE,…
Mike
  • 23,542
  • 14
  • 76
  • 87
8
votes
4 answers

PDO::query() run into "Cannot execute queries while other unbuffered queries are active."

Maybee some other have the same problem than me. I run over the error: Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql,…
lucderheld
  • 91
  • 1
  • 5
6
votes
3 answers

PDO MYSQL_ATTR_USE_BUFFERED_QUERY Not taking affect

I have the following rough code (full code is 146 lines, 90 of which are string parsing, can add if needed): ini_set('memory_limit', '7G'); $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT =>…
user3783243
  • 5,368
  • 5
  • 22
  • 41
3
votes
1 answer

MySQL "Fire-And-Forget" INSERT / UPDATE / DELETE - mysql_unbuffered_query usage advisable?

We have quite a few queries we consider "fire and forget". In the sense that these are just logging inserts, updates and such. Things that are not as critical, and data from which is never used on the front end the users sees. This sounds like an…
anonymous-one
  • 14,454
  • 18
  • 60
  • 84
2
votes
1 answer

Using multiple connections with mysql_unbuffered_query

Is it possible to get around mysql_unbuffered_query()'s limitation of having one query running at a time by opening a second connection? For example, the following code is giving me the error: mysql_select_db(): Function called without first…
Parris Varney
  • 11,320
  • 12
  • 47
  • 76
2
votes
2 answers

PDO connector unable to be used on page with multiple instances

At the top of my php page, I include a connection script called by: include("connector.php") Connector.php setAttribute(PDO::ATTR_ERRMODE,…
JM4
  • 6,740
  • 18
  • 77
  • 125
2
votes
1 answer

Laravel 4.2 open a second database connection to the main database

I have one database for my laravel application but I need to open two connection to it in Laravel for the following reason. I have this code: $pdo = DB::connection()->getPdo(); $pdo->setAttribute( PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false…
Scott
  • 3,967
  • 9
  • 38
  • 56
1
vote
1 answer

PDO General error: 2014 Cannot execute queries while other unbuffered queries are active when trying to LOCK TABLES

I am updating someone's old old code from using mysql() to using PDO. In one place they have some LOCK TABLES commands to prevent two users from accessing the same data at the same time. When running LOCK TABLES, PDO throws "General Error: 2014…
Ben Holness
  • 2,457
  • 3
  • 28
  • 49
1
vote
0 answers

Detect database disconnect in mysql_fetch_row on mysql_unbuffered_query in PHP

I have a code that connects to a database. It executes a select statement over a large table using mysql_unbuffered_query. It goes over the records using mysql_fetch_row and finally frees the result. Sometimes, the server where the code is running,…
Yani
  • 31
  • 4
1
vote
1 answer

SQLite3 Unbuffered Query

I am converting some old code in PHP from SQLite2 to SQLite3. One of the lines uses the following code: $result = sqlite_unbuffered_query($this->db, $sqlite_query); Is it possible to perform an unbuffered query in SQLite3? I can't seem to find…
Breo
  • 31
  • 9
1
vote
1 answer

mysql unbuffered query locking doesn't lock

Evidently according to this: http://www.tuxradar.com/practicalphp/9/4/9 Between the time the call to mysql_unbuffered_query() is issued and your processing the last row, the table remains locked by MySQL and cannot be written to by other…
pillarOfLight
  • 8,592
  • 15
  • 60
  • 90
1
vote
1 answer

Iterate mysqli unbuffered query result more than once

Problem: I have a query that returns a large result set. It is too large to bring into PHP. I get a fatal memory max error and cannot increase memory limit. Unbuffered Queries I need to iterate over the array multiple times but mysqli_data_seek…
km6zla
  • 4,787
  • 2
  • 29
  • 51
0
votes
1 answer

"MySQL server has gone away" while iterating unbuffered query with PHP 7.4 PDO on local MySQL 5.7 database InnoDB

My PHP 7.4 script select a large InnoDB table from a local MySQL 5.7 database and iterates every line using PDO. I'm using unbuffered queries by purpose as the whole table won't fit server memory. The query is a simple SELECT * FROM table WHERE…
Marco Marsala
  • 2,332
  • 5
  • 25
  • 39
0
votes
0 answers

How to run unbuffered SELECT and run another INSERT in the meantime? (Php, MYSQLI_USE_RESULT, Commands out of sync; you can't run this command now)

I have to filter and add records from a master table. This table has millions of records. First I was trying: $result = mysqli_query($myConnection, 'SELECT * FROM master'); while($record = mysqli_fetch_assoc($result)) { if ($myConditionsMet) …
John Smith
  • 6,129
  • 12
  • 68
  • 123
1
2