ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_abstraction:record_insertion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
v5:userguide:learn_abstraction:record_insertion [2016/03/15 14:59] mnewnhamv5:userguide:learn_abstraction:record_insertion [2016/03/20 16:45] – [Inserting A Record] mnewnham
Line 4: Line 4:
 ====== Inserting And Updating Records ====== ====== Inserting And Updating Records ======
 ===== AutoExecute ===== ===== AutoExecute =====
-ADOdb provides a helper routine, [[v5:reference:connection:autoexecute|autoExecute()]]. AutoExecute() simplifies the task of inserting and updating records by providing a structured, easy to understand methodology.+ADOdb provides a helper routine, [[v5:reference:connection:autoexecute|autoExecute()]]. It simplifies the task of inserting and updating records by providing a structured, easy to understand methodology.
 ==== Inserting A Record ==== ==== Inserting A Record ====
 In order to insert a record, it is sufficient to know: In order to insert a record, it is sufficient to know:
Line 26: Line 26:
    
 /* /*
- * result executes "INSERT INTO people (first_name,last_name) values ('Carol',Smith')";+ * result executes "INSERT INTO people (first_name,last_name)  
 +                                values ('Carol',Smith')";
  */  */
 </code> </code>
Line 42: Line 43:
  
 /* /*
- * result executes "UPDATE people SET first_name='Caroline',last_name='Jones' WHERE id=305";+ * result executes "UPDATE people SET first_name='Caroline', 
 +*                                     last_name='Jones'  
 +*                                     WHERE id=305";
  */  */
 </code> </code>
Line 49: Line 52:
 If the record match statement produces a non-unique result set, then **ALL** records that match will be updated. If the record match statement produces a non-unique result set, then **ALL** records that match will be updated.
  
-  "last_name like 'Sm%'"; +<code php> 
 +$db->autoExecute($table, $record, 'UPDATE', "last_name like 'Sm%'")
 +</code>
 ===== Limitations ===== ===== Limitations =====
 AutoExecute is designed to be used as a UX helper, and contains multiple layers of validation which may cause performance issues. For improved performance, use can be made of [[v5:reference:connection:getinsertsql|getInsertSql()]] and [[v5:reference:connection:getupdatesql|getUpdateSql()]]. In OLTP environments, consider crafting inserts/updates programatically and using [[v5:reference:connection:execute|execute()]]   AutoExecute is designed to be used as a UX helper, and contains multiple layers of validation which may cause performance issues. For improved performance, use can be made of [[v5:reference:connection:getinsertsql|getInsertSql()]] and [[v5:reference:connection:getupdatesql|getUpdateSql()]]. In OLTP environments, consider crafting inserts/updates programatically and using [[v5:reference:connection:execute|execute()]]  
  
 <WRAP info 300px center> <WRAP info 300px center>
-**End Of Lesson 1**+**End Of Lesson**
 </WRAP> </WRAP>
v5/userguide/learn_abstraction/record_insertion.txt · Last modified: 2016/03/20 16:48 by mnewnham