Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3319352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:48:52+00:00 2026-05-17T22:48:52+00:00

So this is my current code: function addPage($uniquename, $ordernum, $title, $author, $content, $privilege, $description=NULL,

  • 0

So this is my current code:

function addPage($uniquename, $ordernum, $title, $author, $content, $privilege, $description=NULL, $keywords=NULL){
    if (!$description) $description = NULL;
    if (!$keywords) $keywords = NULL;
    //UPDATE `table` SET `ordernum` = `ordernum` + 1 WHERE `ordernum` >= 2
    $query = "UPDATE ".$this->prefix."page SET ordernum = ordernum+1 WHERE ordernum >= ?";
    if ($stmt = $this->db->prepare($query)){
        $stmt->bind_param("i", $ordernum);
        $stmt->execute();
        if (!arCheck($stmt)) return false;
    } else {
        $this->stmtError("addPage", $stmt->error);
    }

    $query = "INSERT INTO ".$this->prefix."page VALUES (LCASE(?), ?, ?, ?, ?, ?, ?, ?)";
    if ($stmt = $this->db->prepare($query)){
        $stmt->bind_param("sisisssi", $uniquename, $ordernum, $title, $author, $content, $description, $keywords, $privilege);
        $stmt->execute();
        return arCheck($stmt);
    } else {
        $this->stmtError("addPage", $stmt->error);
    }
}

It is suppose to add a new page to the datatable. The MySQL is courtesy of Phil Hunt from Store the order of something in MySQL

I know that you can use multiquery to accomplish the same thing, however I was told that prepared statement is better in performance, and security. Is there another way to do this? Like a prepared multi query?

Also, what about doing Transactions? I’m not fully sure of what that is, I assume that it’s if, let’s say, the INSERT statement fails, it will undo the UPDATE statement as well?

NOTE: the arCheck function will close the statement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:48:53+00:00Added an answer on May 17, 2026 at 10:48 pm

    Prepared statements are indeed faster for repeated queries, at least in most cases. They’re also safer because they automatically escape input values, preventing SQL injection attacks. If you want to use them in PHP you’ll need the MySQLi extension.

    You appear to have the right idea about transactions. With MySQLi there are commit and rollback methods, otherwise you can use mysql_query("COMMIT") or mysql_query("ROLLBACK").

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New
Why does this code fail to display the category name Apples using the current
Current code: $(document).ready(function(){ $('#go').hover( function(){ // Change the input image's source when we roll
I have this jQuery code that retrieves external content using ajax, without refereshing the
If I understand this correctly: Current CPU developing companies like AMD and Intel have
Is there a difference between Cursor.Current and this.Cursor (where this is a WinForm) in
I need a serviceable shell for MSYS. This is my current dilemma: The default
In the constructor of my class, I map the current object ( this ),
My current position is this: if I thoroughly test my ASP.NET applications using web
The current top-voted to this question states: Another one that's not so much a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.