0

I have some problems with MySQL prepared queries. Especially UPDATE and INSERT.

$mysqliStmt->execute();

It does NOT update or insert into a table. It just delivers stmt results. There are no errors, warnings, or anything else. (See below)

The Insert query I use:

INSERT INTO testdatabase.`test` (`test1`, `test2`) VALUES(?, ?)

The Update query:

UPDATE testdatabase.`test` SET `test1` = ? WHERE `id` = ? LIMIT 1

Resultinformation (update):

'fieldCount' => 0,
'affectedRows' => 1,
'numRows' => 0,
'paramCount' => 2,
'insertId' => 0,
'sqlstate' => '00000',
'threadId' => 5291,
'errno' => 0,
'error' => '',
'warningCount' => 0,
'warnings' => false
'connectErrno' => 0,
'connectError' => NULL,
'hostInfo' => 'Localhost via UNIX socket',
'protocolVersion' => 10,
'serverInfo' => '5.1.49-3',
'serverVersion' => 50149,
'clientInfo' => '5.0.27',
'clientVersion' => 50027,
'info' => 'Rows matched: 1  Changed: 1  Warnings: 0'

The code:

$stmt = self::$_connection->prepare($query);
//binds params -> like/with $stmt::bind_param() but more generic
$this->_bindParameters($stmt) 
$stmt->execute();

Now the update/insert data should be stored into database or I'm wrong?

If I use phpMyAdmin or MySQL console to verify the results of the queries, the database table was neither updated nor was the new data inserted.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Is autocommit turned on? – ppeterka Feb 22 '13 at 14:21
  • Yes. Its turned on. The if i do a SELECT after the UPDATE/INSERT it will return the results of UPDATE/INSERT correctly. But it is NOT stored in the database if i check it with console or phpmyadmin. – Warin Koslowski Feb 25 '13 at 07:30
  • After i checked the class again i found the problem. You were right ppeterka. Autocommit was disabled because one method set it to false and that was the error. Thank you very much :) – Warin Koslowski Feb 25 '13 at 07:42

0 Answers0