1

I am using transactions for the first time and I have a few questions.

1) Why am I getting a "Call to a member function autocommit() on a non-object" error

2) Am I properly storing results of the transaction in a $result variable as I try to do below so that I can run the below IF statement?

3) Can I add joins into the transaction queries like with any other query?

$mysqli = $wpdb; //call to wordpress database

$mysqli->autocommit(false);

$mysqli->$query("INSERT INTO stories (ID, category, genre, story_name, active)  VALUES
('$user_ID', '$category', '$genre','$story_name', '1')");

$mysqli->$query("INSERT INTO writing (ID, text, position, approved) 
VALUES('$user_ID', '$text', '1','N')");

$myqli->commit();


$result = $mysqli($query);
if($result)
{  echo("Your article is underway!");}
else { echo("Article failed");}
user5000
  • 129
  • 1
  • 9
  • 1. are you sure/checked that `$mysqli` is a `mysqli` object? `var_dump($mysqli)` to find out 2. it should be `$mysqli->query` the method. just get the affected rows. for more info check out this [answer](http://stackoverflow.com/questions/5372453/mysqli-prepared-statements-and-transactions) also here on SO, it may shed some light, [this too](http://stackoverflow.com/questions/19106963/php-prepared-statements-and-transactions-in-a-loop), uses prepared statements – Kevin Aug 03 '14 at 06:13

0 Answers0