0

I have create a MySQL procedure as follow:

  delimiter $$
  create procedure procTest()
  begin
    insert into tSystemLog (note) values("in Precedure: 
              tOperation_Insert");
  end$$
  delimiter;

and call from my PHP code as follow:

$SqlConn = new mysqli("localhost", "root", "131313", "FamilyTest");
if($SqlConn->connect_error) {
    echo("Fail: " . $conn->connect_error);
} else echo "Success";
$sSql = "insert into tSystemLog (note) values('111')";
$SqlConn->query($sSql);
$SqlConn->query("call procTest()");

system do not give any message, but in the table tSystemLog, I can find the record "111", and can not find the record "in Precedure:tOperation_Insert".

if I call procTest() from workbench, it is ok, I can find the "in Precedure:tOperation_Insert" record in table tSystemLog.

I have try to use PDO connection, it is same. this procedure does not perform.

jarlh
  • 42,561
  • 8
  • 45
  • 63
yang0111
  • 1
  • 1
  • 7
    You say "system do not give any message", but you're not checking for any. https://www.php.net/manual/en/mysqli.error.php – ceejayoz Mar 27 '19 at 21:05
  • 2
    `echo $SqlConn->error;` at the end of your code - does this contain any clues? – Scoots Mar 27 '19 at 21:05
  • Thanks everyone, I find the problem, tSystemLog use the datetime as the primary key. I have insert two records in the same time, so the second record was refused by the primary key. – yang0111 Mar 27 '19 at 21:15
  • 1
    [How to enable MySQLi exception mode?](https://stackoverflow.com/questions/14578243/turning-query-errors-to-exceptions-in-mysqli) – Dharman Mar 27 '19 at 21:15

0 Answers0