Home  >  Article  >  Backend Development  >  Example of php sqlite_create_function function

Example of php sqlite_create_function function

WBOY
WBOYOriginal
2016-07-25 08:57:441047browse
  1. /**

  2. * sqlite_create_function function example
  3. * edit: bbs.it-home.org
  4. */
  5. define("PPO",400);
  6. function my($salary){
  7. return $salary / PPO;
  8. }
  9. $sqldb = sqlite_open("mydatabase.db");
  10. sqlite_create_function($sqldb,"myFunction", "my", 1);
  11. $query = "select myFunction(salary) FROM employee WHERE empid=1";
  12. $result = sqlite_query($sqldb, $query);
  13. list($myFunction) = sqlite_fetch_array($result);

  14. echo "The employee can purchase: ".$myFunction." ounces.";

  15. sqlite_close($sqldb);

  16. ?>

复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn