1. General insert$query = "INSERT into profile (userName) VALUES (' {$userName} ')"; $this->db->query ($query); $userId = sprintf ("%d", $this->db->insert_id); $this->db->commit (); 2. If there is an update in the database, then insert $query = "INSERT into Bookread (UserId, BookId, Count) VALUES ($_userid, $_bookid, 1) on DUPLICATE KEY UPDATE count = count + 1 "; $this->db->query ($query); $this->db->commit (); 3. Update $query = "Update profile Set devicetoken= ' {$_token} ' WHERE Userid=$_userid"; $this->db->query ($query); $this->db->commit (); 4. Query 1, the operation needs to manipulate the field $stmt = $this->db->prepare (' SELECT userId, PassWord from the profile WHERE username=? '); $stmt->bind_param ("s", $_username); $rs = $stmt->execute (); $stmt->bind_result ($_userid, $_password); while ($stmt->fetch ()) { Break } $stmt->close (); Query 2, return the query result array $query = "Select name, points from profile WHERE 1 ORDER by points DESC LIMIT $_from, $_to"; if ($result = $this->db->query ($query)) {while ($row = $result->fetch_row ()) { $ret = Array ("name" = = $row [0], "points" = = $row [1],); } $result->close (); }
http://www.bkjia.com/PHPjc/477688.html www.bkjia.com true http://www.bkjia.com/PHPjc/477688.html techarticle 1. General Insert $query = INSERT INTO profile ({$userName}), $this-db-query ($query), $userId = sprintf (% userName) D, $this-db-insert_id); $this-db-commit (); 2. In the database as ...