本节内容:
sqlite_create_function函数的例子
例子:
<?php
/**
* sqlite_create_function函数示例
* edit: www.jb200.com
*/
define("PPO",400);
function my($salary){
return $salary / PPO;
}
$sqldb = sqlite_open("mydatabase.db");
sqlite_create_function($sqldb,"myFunction", "my", 1);
$query = "select myFunction(salary) FROM employee WHERE empid=1";
$result = sqlite_query($sqldb, $query);
list($myFunction) = sqlite_fetch_array($result);
echo "The employee can purchase: ".$myFunction." ounces.";
sqlite_close($sqldb);
?>