欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php sqlite_create_function函数的例子

程序员文章站 2022-04-08 18:29:09
...
  1. /**

  2. * sqlite_create_function函数示例
  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. ?>
复制代码