1

I'm running a number of MySQL queries in php with the following code:

$this->conection = new mysqli($this->server, $this->user, $this->pass, $this->db);

$query = "call createNew(....)";//the triple dots represent the parameters, of course, and createNew() is a stored procedure in my database
$consult = $this->conection->query($query);

$query2 = "call loadNewID(....)";
$consult2 = $this->conection->query($query2);

$query3 = "call loadNewID(....)";//same stored procedure as the previous one, but with different parameters
$consult3 = $this->conection->query($query3);

So the problem is that consult and consult2 work just fine and return "1" as they should, but consult3 doesn't work and returns nothing. The curious thing is that if I avoid running query2 and consult2 lines of code, query3 and consult3 work just fine. That's why the only conclusion that makes sense to me is that there is some kind of limit of queries that you can run in a php file... could someone perhaps tell me if I'm right or wrong about this? or how can I fix my problem and make all the queries work?

  • No, there is no such limitation, these will put into queues. This may helps, http://stackoverflow.com/questions/41255750/how-does-laravel-store-and-process-the-requests – LF00 May 05 '17 at 07:40
  • `$this->conexion->query()`, shouldnt this be `$this->connection->query()`? – creativename May 05 '17 at 07:41
  • if query one is returning expected result do one thing that is put the query2 again after query3 which is not working properly and see query2 is returning result or not. if yes, then there is some problem with query3 – Exprator May 05 '17 at 07:41
  • and from the code you are using conexion instead of connection? change it – Exprator May 05 '17 at 07:44
  • I changed the "conexion" for "conection", thanks for letting me know of that mistake, however that mistake was just in this post, my code is correct, so that is not the problem – Arturo Ibarra May 05 '17 at 07:46
  • Are you sure the problem is in the php code and not in the stored procedures? What happen if you call the procedures in the same order with the same parameters in a console? – rypskar May 05 '17 at 08:08
  • @ArturoIbarra Have you tried var dumping `$query3` or `$consult3`? Also try to do what @Exprator said a couple comments above – creativename May 05 '17 at 08:09
  • @rypskar yes, I'm sure, I ran the same queries with the same values in mysql workbench and they work fine. – Arturo Ibarra May 05 '17 at 08:20
  • @creativename I tried what you said and what exprator said as well, but the only query that works is the first one that comes in my php code – Arturo Ibarra May 05 '17 at 08:22
  • Try commenting out query2 and see if query3 runs on its own. – Jaydee May 05 '17 at 08:57
  • @jaydee it does, I actually pointed that out in the post hehe, that's the weird thing – Arturo Ibarra May 05 '17 at 09:06

1 Answers1

0

I finally got it to work, guys! I called $this->conection->close(); after all my queries and then open the conection with mysql again before every query and now it works :D Thanks for the help!