j9sjam3 Posted April 1, 2011 Share Posted April 1, 2011 Hello again. I have built a multi-insert MySQLi function. The problem is, I cannot retreive the ID from each query. If you could help, that would be brilliant. <?php public function Query($sql) { $this->IsConnected(); $this->timeStart = microtime(true); $this->queries = $sql; // $sql is below $this->StartTransaction(); $this->lastResult = mysqli_multi_query($this->link, $sql); if($result = mysqli_store_result($this->link)) { $this->lastID .= mysqli_insert_id($this->link); mysqli_free_result($result); } while(mysqli_next_result($this->link)); if(!$this->lastResult) { $this->RollbackTransaction(); $this->Error(null, 0, __LINE__); } $this->EndTransaction(); if(strpos(strtolower($sql), "insert") === 0) { echo $this->lastID; if(!$this->lastID) { $this->Error("", 0, __LINE__); } else { return $this->lastResult; $this->queryQueue = ""; } } elseif(strpos(strtolower($sql), "select") === 0) { $this->LastID = 0; } $this->timeEnd = microtime(true); $this->timeTotal = ($this->timeEnd - $this->timeStart); $removeE = explode('E', $this->timeTotal); $this->timeTotal = $removeE[0]; $sql var <?php $sql = "INSERT INTO users (username, password) VALUES ('1', 'Jsa');INSERT INTO users (username, password) VALUES ('2', 'Jsa');INSERT INTO users (username, password) VALUES ('2', 'Jsa');INSERT INTO users (username, password) VALUES ('2', 'Jsa');"; Thanks. Quote Link to comment Share on other sites More sharing options...
j9sjam3 Posted April 1, 2011 Author Share Posted April 1, 2011 Can anyone help? Would be much appreciated... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.