<?php
class OrdersModel
{
public static function wishlistcreate($item, $user, $username){
$database = DatabaseFactory::getFactory()->getConnection();
$btc = System::bitcoinconnect();
//get the wishlist product, where username and still for sale
$wishlist = $database->prepare("SELECT * FROM products INNER JOIN wishlist ON wishlist.wishlist_product=products.id WHERE wishlist_username=? AND products.enddate > NOW() AND products.quantity > 0 AND products.enabled=1");
$wishlist->execute(array($user));
$product = $wishlist->fetch();
if($product):
$get_user_information = $database->prepare("SELECT * FROM users WHERE username=?");
$get_user_information->execute(array($user));
$user_result = $get_user_information->fetch();
$createorder = $database->prepare("INSERT INTO orders(orders_username,orders_amount,orders_product,orders_firstname, orders_lastname, orders_address1, orders_address2, orders_zipcode, orders_city, orders_country, orders_btcaddress, orders_status,orders_wishlist, orders_wishlist_user) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
//get btc address, check it's valid, then if isset run query below
$createorder->execute(array($username->username, $product->price + $product->shippingcost, $product->wishlist_product, $user_result->firstname, $user_result->lastname, $user_result->address1, $user_result->address2, $user_result->zipcode, $user_result->city, $user_result->country, $btc->getnewaddress(), 0, 1, $user,));
else:
echo 'nahhh'; //dbg
//error, item has ended or item not in users watch list.
endif;
}
我收到错误:
致命错误:无法重新声明类比特币
这是另一个文件中的类,这是我的$btc函数:
public static function bitcoinconnect() {
include Config::get('PATH_LIBS')."jsonRPCClient.php";
//connect to bitcoin rpc use https ALWAYS!!
$bitcoin = new Bitcoin("yadda");
return $bitcoin;
}
我正在使用 mvc,所以每个函数都算作一个页面,但我使用了
$btc = System::bitcoinconnect();
在另一个函数/页面中,我如何只为所有文件声明上述代码,这样我就不会得到无法重新声明的类。
public static function bitcoinconnect() {
include_once Config::get('PATH_LIBS')."jsonRPCClient.php";
//connect to bitcoin rpc use https ALWAYS!!
$bitcoin = new Bitcoin("yadda");
return $bitcoin;
}