php シングルトンの問題
これは私のシングルトンです:
include_once 'conn/mysql.class.php';
//データベース接続シングルトン
クラスシングルトン{
protected static $conn=null;
//インスタンス化を防止します
プライベート関数 __construct(){}
//クローン作成を防止
プライベート関数 __clone(){}
//単一のケース
public static function get(){
If(self::$conn == null){
self::$conn=new MyDb();
}
return self::$conn;
}
}
クラス操作:
include_once 'dbio/Singleton.class.php';
//continfo テーブル操作クラス
クラスコンテンツ{
//すべてのレコードをクエリします
パブリック静的関数 getContent(){
$arr=array(); //すべてのレコードを保存します
$sql='select * from continfo ';
$conn=Singleton::get();
$ccc=シングルトン::get();
var_dump($conn);
var_dump($ccc);
$row=$conn->executeQuery($sql);
var_dump($row);
for($i=0;$i
$conn->set($i);
$arr1=array( // レコードを保存します
"contid"=>$conn->getValue(0),
"userid"=>$conn->getValue(1),
"sendUser"=>$conn->getValue(2),
"title"=>$conn->getValue(3),
"content"=>$conn->getValue(4),
"isLock"=>$conn->getValue(5),
"imageSrc"=>$conn->getValue(6),
"contTime"=>$conn->getValue(7)
);
$arr[]=$arr1; // 配列にレコードを追加します
}
$conn->close();
$arr を返します;
}
}
問題は、このクラス メソッドがデータベース内のデータを取得できないことです。