Sunday, 15 January 2012

php - SQL insert into select issue -


So I think I'm close to finding this but my query does not add items from the "pending" table "item" Can you help me with this in the table? In addition, if I want to remove it after removing it, should I add the code below INSERT to the search query? Thanks

action.php:

  $ sql = "Select items (picture, title, description, name) from pending (photo, title, description, name) Include in "; $ Stmt = $ conn- & gt; Ready ($ sql); $ Stmt- & gt; Executed (); Example for deleting the query after moving items from "Pending" to item:  
  $ idToDelete = filter_var ($ _ POST ["recordToDelete "], FILTER_SANITIZE_NUMBER_INT); // We try to delete the records using the Record ID received from $ POST $ sql = "Delete the pending WHERE id =: id"; $ Stmt = $ conn- & gt; Ready ($ sql); $ Stmt- & gt; Baidam Parm (': ID', $ idToDelete, PDO :: Paramax); $ Stmt- & gt; Executed ();  

I think you're mistakenly doing yourself this way.

Notice that if you add a new line to the pending queue after issuing INSERT SELECT , before you start your deletion.

I think you have copied from pending in pending to make sure that you have a single loop There is a need to do this in more controlled ways.

  $ sql = "Select picture, title, description, name from pending"; $ Select_pending = $ conn- & gt; Ready ($ sql); $ Select_pending- & gt; Executed (); $ Sql ​​= "Enter item (picture, title, description, name) values ​​(: photo, title :: description, name)"; $ Insert_items = $ conn- & gt; Ready ($ sql); $ Sql ​​= "Delete pending WHERE id =: id"; $ Delete_pending = $ conn- & gt; Ready ($ sql); // Only if you are using the INNODB database // $ conn- & gt; BeginTransaction (); While ($ row = $ select_pending-> fetch_object ()) {$ insert_items-> Bindamaram (': photo', $ row-> photo, PDO :: PARAM_STR); $ Insert_items- & gt; Bind Parm (': Title', $ Row-> Title, PDO :: Param_st); $ Insert_items- & gt; Binamaram (': Details', $ line-> Description, PDO: Parama_ast); $ Insert_items- & gt; Binaparam (': name', $ line-> name, PDO :: param_st); $ Insert_items- & gt; Executed (); $ Delete_pending- & gt; Bind_param (': id', $ row-> id, PDO :: PARAM_INT); $ Delete_pending- & gt; Executed (); } // Only if you are using the INNODB database // $ conn- & gt; Committed ();  

No comments:

Post a Comment