Langsung ke konten utama

Postingan

Menampilkan postingan dengan label internet

Delete indexeddb data by index

var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB; var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || { READ_WRITE: "readwrite" };; var db; var transaction, objectStore; var request = indexedDB.open("IndexedDBname", 1);         request.onsuccess = function (evt) {        db = request.result;  var deleteindex = db.transaction(["indexdbtable"], "readwrite") .objectStore("indexdbtable")                 .delete(1); // example if you want to delete index no 1 deleteindex.onsuccess = function(event) { console.log("index 1 deleted" + "indexdbtable");  // log };  };

Function to delete Indexeddb Object(table)

var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB; var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || { READ_WRITE: "readwrite" };; var db; var transaction, objectStore; // "IndexDB" is your indexed db name (database) var request = indexedDB.open("IndexDB", 1);         request.onsuccess = function (evt) {         db = request.result; //"indexobject" is your indexdb object (table) transaction = db.transaction("indexobject", "readwrite"); objectStore = transaction.objectStore("indexobject");   // clear all the data out of the object store var objectStoreRequest = objectStore.clear(); objectStoreRequest.onsuccess = function(event) {     // report the success of our clear operation console.log('clear '+"indexobject"); }; };

IndexedDB Fuzzy Search

This is how to create  key range between the search term and the search term with a 'z' letter at the final. db . transaction ([ 'table' ], 'readonly' ) . objectStore ( 'table' ) . openCursor ( IDBKeyRange . bound ( searchTerm , searchTerm + '\uffff' ), // The important part, thank Velmont to point out 'prev' ) . onsuccess = function ( e ) { e || ( e = event ); var cursor = e . target . result ; if ( cursor ) { // console.log(cursor.value.column1 + ' = ' + cursor.value.column2); cursor . continue (); } }; If you need to order the result, so I defined a array before the transaction, then we call it when we loaded all data, like this: var result = []; db . transaction ([ 'table' ], 'readonly' ) . objectStore ( 'table' ) . openCursor ( IDBKeyRange . bound ( searchTerm , searchTerm + '\uffff' ), // The important ...

Use HTML5 IndexedDB cursors to update existing records

The  HTML5   IndexedDB  is still in the working draft stage and not fully implemented in major Internet browsers yet. Nevertheless, I tried to use its asynchronous API to develop a  Google Maps  application. It took me a little while to figure out how to update an existing record in the IndexedDB  database store. This can be done by opening a read-write cursor to the record to be updated. Then call the cursor  update  method to replace it with the new record. An example Javascript code snippet is shown below. try { var objDb; //the database to update var store = 'myStore' ; //the database store to update var key = 88; //the key of the existing record to update var newRec = 'hello world' ; //the new record var objStore = null ; var objTrans = null ; var objCursor = null ; var objKeyRange = null ;   //...etc...open the database....etc... //open a read-write transaction objTrans = objDb.transaction(store,...

A Simple Example : Sending Email with Attachment Using Phpmailer

PHPMailer is a PHP class that provides a package of functions to send email . The two primary features are sending HTML Email and e-mails with attachments . PHPMailer supports nearly all possiblities to send email :  mail()  , Sendmail  ,  qmail  & direct to SMTP server (ie sending email via your Google mail-account ) . You can use any feature of SMTP-based e-mail , multiple recepients via : to , CC , BCC , etc. In short: PHPMailer is an efficient way to send e-mail within PHP . As you may know, it is simple to send mails with the PHP  mail()  function . So why use PHPMailer ? Isn’t it slower ? Yes that’s true , but PHPMailer makes it easy to send e-mail , makes it possible to attach files , send HTML e-mail , etc . With PHPMailer you can even use your own SMTP server and avoid Sendmail routines used by the  mail()  function on *nix platforms . The following code snippet demonstrates how to implement the class into your script or web...