当前位置:Gxlcms > PHP教程 > phpsqlite_create_function函数的例子

phpsqlite_create_function函数的例子

时间:2021-07-01 10:21:17 帮助过:4人阅读

  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. ?>

人气教程排行