topical media & game development

talk show tell print

server-php-sqlite-demo-function.php / php

  /* determine the difference between the user supplied string and the one in the database based on the contained characters */
  function char_compare(db_str, user_str) {
      return similar_text(db_str, user_str);
  db = new SQLiteDatabase("server-php-sqlite-demo.db");
  /* Create char_compare() function inside SQLite based on our PHP function, char_compare(). The 3rd parameter indicates how many arguments the function requires */
  db->createFunction('char_compare', 'char_compare', 2);
  /* Execute query, where char_compare() is used to perform the string comparison between name & specified string */
  res = db->arrayQuery("SELECT name, char_compare(name, 'Il2') AS sim_index FROM foo", SQLITE_ASSOC);

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.