【发布时间】:2011-10-25 17:36:55
【问题描述】:
我基本上是在尝试将 GET 值从构造函数传递给 insert_update 函数。我已经去掉了很多后者的功能。另外,如果值得注意的话,这个页面是一个包含页面。
class Updates {
function __construct(){
$owner = $this->get = array_map('mysql_real_escape_string', $_GET);
$owner=$owner["member_id"];
echo $owner;
}
//Insert Update
public function Insert_Update()
{
$query = mysql_query("INSERT INTO `field` (foo) VALUES (N'$owner')") or die(mysql_error());
}
【问题讨论】:
-
我有点困惑。构造函数中的 $owner var 是什么?您想在构造函数中从 get 中获取 member_id 并在 insert_update 方法中使用它?
-
这正是我想做的。
-
在 SQL 查询中 - 你想要所有来自 post 的东西吗?还是只是 member_id ?
-
为什么不在 insert_update 中使用 $this->get['member_id']?
-
你的意思是没有构造函数?
标签: php oop class function methods