hehexu

博客园 首页 新随笔 联系 订阅 管理
static function RowToObject($dbRow){
$st=new SensorTemplate();
$st->TemplateID=$dbRow["TemplateID"];
$st->ManufacturerID=$dbRow["ManufacturerID"];
$st->Model=$dbRow["Model"];
$st->TemperatureOID=$dbRow["TemperatureOID"];
$st->HumidityOID=$dbRow["HumidityOID"];
$st->TempMultiplier=$dbRow["TempMultiplier"];
$st->HumidityMultiplier=$dbRow["HumidityMultiplier"];
$st->mUnits=$dbRow["mUnits"];
return $st;
}

//该方法将数据存储到一个实例对象中,而不是存储到$this类本身
foreach(SensorTemplate::RowToObject($sensorRow) as $prop => $value){
$this->$prop=$value; //$prop=temp
}
 $this->$prop=$value;   //$this->temp=$value;
 $this->$prop 指的是对应的变量名称对应值


posted on 2018-01-20 09:11  hehexu  阅读(150)  评论(0编辑  收藏  举报