に私は大きな問題を持っている\:
私は」フレームワークなしで新しいWebAppを作成します。 私はxamppと崇高なテキストを使用しています。 私はこの問題をどのように解決できるのか分かりません。
私をdb.phpは、私はなぜエラーが来ている?多分
require_once 'core/init.php';
// echo Config::getir('mysql/host');
// calismadi $kullanici = DB::baglan() -> query("SELECT kullanici_adi FROM uye WHERE kullanici_adi = ?", array('oguzhan'));
$kullanici = DB::baglan()->getir('uye', array('kullanici_adi', '=', 'oguzhan'));
if ($kullanici->hatalar()) {
echo 'Kullanıcı yok';
}else{
echo 'Var';
}
をロードしています私のindex.phpで
class DB{
private static $_baglan = null;
private $_pdo,
$_query,
$hatalar = false,
$sonuc,
$_sayac = 0;
public function __construct(){
try{
$this -> _pdo = new PDO('mysql:host=' . Config::getir('mysql/host') . ';dbname=' . Config::getir('mysql/db'), Config::getir('mysql/kullanici_adi'), Config::getir('mysql/sifre'));
// echo 'baglandi';
}catch(PDOException $e){
die($e->getMessage());
}
}
public static function baglan(){
if (!isset(self::$_baglan)) {
self::$_baglan = new DB();
// echo 'baglandi';
}
return self::$_baglan;
}
public static function query($sql, $parametre=array()){
$this->_hatalar = false; // line 32
if ($this->_query = $this->_pdo->prepare($sql)) {
$x = 1;
if (count($parametre)) {
foreach ($parametre as $param) {
$this->_query->bindValue($x, $parametre);
$x++;
}
}
if ($this->_query->execute()) {
$this->sonuc=$this->_query->fetchAll(PDO::FETCH_OBJ);
$this->_sayac=$this->_query->rowCount();
}else{
$this->_hatalar=true;
}
}
return $this;
}
public function eylem($eylem, $tablo, $where=array()){
if (count($where)===3) {
$operatorler = array('=', '<', '>', '>=', '<=');
$alan = $where[0];
$operator = $where[1];
$deger = $where[2];
if (in_array($operator, $operatorler)) {
$sql = "{$eylem} FROM {$tablo} WHERE {$alan} {$operator} ?";
if (!$this->query($sql, array($deger))->hatalar()) {
return $this;
}
}
}
return false;
}
public function getir($tablo, $where){
return $this->eylem('SELECT *', $tablo, $where);
}
public function sil($tablo, $where){
return $this->eylem('DELETE', $tablo, $where);
}
public function hatalar(){
return $this->hatalar();
}
}
を書かれた方法の例