PDA

View Full Version : سوال: من در حال طراحی یک cms هستم و کد کلاس کاربران را نوشتم اما با ارور مواجه شده ام لطفا راهنمایی کنید



ramezani72
پنج شنبه 16 خرداد 1398, 15:40 عصر
<?php


class User{

public $id; // key
public $username;
public $password;
public $first_name;
public $last_name;


public static function find_all_users(){ // پیدا کردن تمام کاربران



return self::find_this_query("select * from users"); // استفاده از متد دیگر در اینجا

}

public static function find_user_by_id($user_id){ // برای پیدا کردن کاربر بر مبنای ای دی

$result_set=self::find_this_query("select * from users where id= $user_id"); // استفاده از متد دیگر در اینجا




$found_user=mysqli_fetch_array($result_set);
return $found_user;

}

public static function find_this_query($sql){
global $database;
$result_set=$database->queryi($sql);
$the_object_array= array();
while($row = mysqli_fetch_array($result_set)){
$the_object_array[]=self::instantioan($row);

}
return $the_object_array;


}

public static function instantioan($the_record){

$the_object=new self;

foreach($the_record as $the_attribute -> $valuee){
if($the_object->has_the_attribute($the_attribute)){
$the_object->$the_attribute = $valuee;
}
}

return $the_object;
}
private function has_the_attribute($the_attribute){
$object_properties= get_object_vars($this);
return array_key_exists($the_attribute,$object_properties );





}


}


?>


Notice: Undefined variable: valuee in C:\xampp\htdocs\gallery\admin\includes\user.php on line 46

Warning: Creating default object from empty value in C:\xampp\htdocs\gallery\admin\includes\user.php on line 46

Warning: array_key_exists(): The first argument should be either a string or an integer in C:\xampp\htdocs\gallery\admin\includes\user.php on line 56

Notice: Undefined variable: valuee in C:\xampp\htdocs\gallery\admin\includes\user.php on line 46

Warning: array_key_exists(): The first argument should be either a string or an integer in C:\xampp\htdocs\gallery\admin\includes\user.php on line 56

Notice: Undefined variable: valuee in C:\xampp\htdocs\gallery\admin\includes\user.php on line 46

plague
جمعه 17 خرداد 1398, 14:13 عصر
foreach($the_record as $the_attribute -> $valuee)

باید بشه


foreach($the_record as $the_attribute=>$valuee)

ramezani72
یک شنبه 19 خرداد 1398, 00:50 صبح
foreach($the_record as $the_attribute -> $valuee)

باید بشه


foreach($the_record as $the_attribute=>$valuee)


خدا خیرت بده درست شد