LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2016, 11:11 AM   #1
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Question PHP-7: #2 mysqli query returns "no results" unless #1 query is closed first


I have a PHP routine that tries to execute two queries, one after the other, and to iterate through the result-set of both.

However, I am finding that, unless I explicitly do a "mysqli_stmt::close()" on the first statement, the second statement(s), although they appear to run, produce no results. (The "affected count," e.g. of a SELECT statement, is zero.)

PHP-7 on the latest Ubuntu.

I'm at a loss to explain this behavior.
 
Old 05-19-2016, 11:56 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
$mysqli_stmt->affected_rows returns affected rows with an insert, update or delete query
$mysqli_stmt->num_rows returns rows with a select query but you may need a $mysqli_stmt->store_result() before
 
Old 05-20-2016, 12:43 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
(I might have heard something about mysqli being 'less paralelly useable' than mysql. Did your try it with option USE_RESULT or STORE_RESULT?)
 
Old 05-20-2016, 06:44 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659

Original Poster
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Goofy updates: if I close() the first statement-object (my code actually uses a "wrapper" class which encapsulates both a statement and a result handle ...), the next one runs fine.

G-o-o-f-y: If you use different PHP variables each time to store the object (returned by a static "query()" method), it also works. But, if you assign the new object to the same variable ... even though it is obviously a new and different object-instance ... it will not work.

I have an explicit destructor in the object to explicitly close and discard the mysqli objects. I can see that this destructor is running timely. It does not affect anything.

I suspect a flaw either in mysqli or, just as likely, PHP-7 itself.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Query regarding performance-differences, in using a "servlet" VS "PHP module" ajaygarg Linux - Newbie 1 08-11-2013 06:03 AM
PHP "Object of class mysqli could not be converted to string " Randall Slack Programming 1 12-02-2011 10:02 AM
which is better "mysql" or "mysqli" to use in php 5.2.6 !? robertjinx Linux - Server 1 12-07-2008 08:32 AM
KPPP "Query Modem" returns empty fields ananya Linux - Hardware 2 02-21-2005 10:50 PM
KPPP "Query Modem" returns empty fields ananya Linux - Software 1 02-21-2005 10:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration