Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/02/2013, 13:29
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 17 años, 7 meses
Puntos: 1567
Respuesta: HTML, transacciones y base de datos??

http://dev.w3.org/html5/webdatabase/
Por el momento, solo he visto resultados conectando a Sqlite, en bases de datos que se almacenan en el cliente, y funciona en Opera(12.14) Chrome y Safari
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>SQL Storage</title>
  6. </head>
  7. <br />
  8. <br />
  9. <div align="center"><input type="hidden" id="id" /> First name:<input type="text" id="firstName" /><br />
  10. Last name:<input type="text" id="lastName" /><br />
  11. Phone: <input type="text" id="phone" /><br />
  12. <button onclick="resetForm()">Reset Form</button> <button onclick="updateRecord()">Update</button> <button onclick="insertRecord()">Insert</button> <button onclick="dropTable()">Drop Table</button>
  13. <div id="results"></div>
  14. </div>
  15. <script type="text/javascript">
  16. //<![CDATA[
  17.  
  18. var results = document.getElementById('results');
  19. var id = document.getElementById('id');
  20. var firstName = document.getElementById('firstName');  
  21. var lastName = document.getElementById('lastName');  
  22. var phone = document.getElementById('phone');
  23.  
  24. var createStatement = "CREATE TABLE IF NOT EXISTS Contacts (id INTEGER PRIMARY KEY AUTOINCREMENT, firstName TEXT, lastName TEXT, phone TEXT)";
  25. var selectAllStatement = "SELECT * FROM Contacts";
  26. var insertStatement = "INSERT INTO Contacts (firstName, lastName, phone) VALUES (?, ?, ?)";
  27. var updateStatement = "UPDATE Contacts SET firstName = ?, lastName = ?, phone = ? WHERE id = ?";
  28. var deleteStatement = "DELETE FROM Contacts WHERE id=?";
  29. var dropStatement = "DROP TABLE Contacts";
  30.  
  31. var db = openDatabase("AddressBook", "1.0", "Address Book", 200000);
  32. var dataset;
  33. createTable();
  34.  
  35.      function onError(tx, error) {
  36.        alert(error.message);
  37.      }
  38.      
  39.      function showRecords() {
  40.        results.innerHTML = '';
  41.        db.transaction(function(tx) {
  42.          tx.executeSql(selectAllStatement, [], function(tx, result) {
  43. dataset = result.rows;
  44.            for (var i = 0, item = null; i < dataset.length; i++) {
  45.              item = dataset.item(i);
  46.              results.innerHTML +=
  47.                  '<li>' + item['lastName'] + ' , ' + item['firstName'] + ' <a href="#" onclick="loadRecord('+i+')">edit<\/a>  ' +  
  48. '<a href="#" onclick="deleteRecord('+item['id']+')">delete<\/a><\/li>';
  49. }
  50.          });
  51.        });
  52.      }
  53.      
  54.      function createTable() {
  55.        db.transaction(function(tx) {
  56.          tx.executeSql(createStatement, [], showRecords, onError);
  57.        });
  58.      }
  59.      
  60.      function insertRecord() {
  61.        db.transaction(function(tx) {
  62.          tx.executeSql(insertStatement, [firstName.value, lastName.value, phone.value], loadAndReset, onError);
  63.        });
  64.      }
  65.      
  66. function loadRecord(i) {
  67. var item = dataset.item(i);
  68.        firstName.value = item['firstName'];
  69. lastName.value = item['lastName'];
  70. phone.value = item['phone'];
  71. id.value = item['id'];
  72.      }
  73.  
  74.      function updateRecord() {
  75.        db.transaction(function(tx) {
  76.          tx.executeSql(updateStatement, [firstName.value, lastName.value, phone.value, id.value], loadAndReset, onError);
  77.        });
  78.      }
  79.      
  80.      function deleteRecord(id) {
  81.        db.transaction(function(tx) {
  82.          tx.executeSql(deleteStatement, [id], showRecords, onError);
  83.        });
  84. resetForm();
  85.      }
  86.      
  87.      function dropTable() {
  88.        db.transaction(function(tx) {
  89.          tx.executeSql(dropStatement, [], showRecords, onError);
  90.        });
  91. resetForm();
  92.      }
  93.  
  94. function loadAndReset(){
  95. resetForm();
  96. showRecords();
  97. }
  98.  
  99. function resetForm(){
  100. firstName.value = '';
  101. lastName.value = '';
  102. phone.value = '';
  103. id.value = '';
  104. }
  105. //]]>
  106. </script>
  107. </body>
  108. </html>
código extraido de
http://cookbooks.adobe.com/post_Stor...ase-19115.html

También he visto cosas como esta
http://www.sequelsphere.com/
Pero nunca lo probé


Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.