PDA

View Full Version : سوال: چک کردن مقدار Property



navid3d_69
جمعه 10 آذر 1391, 10:34 صبح
سلام من میخوام توی این کلاس اگر این $Shomare_Factor قبلا مقدار id رو در خودش ذخیره کردن بود دیگه اون متد اجرا نشه باید چی کار کنم؟




class invoice{

public $Shomare_Factor;

public function Getid(){



$firstinsert = mysql_query("INSERT INTO invoice (Name) values('')");

if($firstinsert == true){

$this->Shomare_Factor = mysql_insert_id();


}
}

plague
جمعه 10 آذر 1391, 10:38 صبح
class invoice{

public $Shomare_Factor = false ;

public function Getid(){


if($this->Shomare_Factor){return ;}

$firstinsert = mysql_query("INSERT INTO invoice (Name) values('')");

if($firstinsert == true){

$this->Shomare_Factor = mysql_insert_id();


}
}

navid3d_69
جمعه 10 آذر 1391, 10:41 صبح
تست کردم بازم کار نمی کنه