关于查询返回实体的有关问题

WBOY
リリース: 2016-06-13 10:20:19
オリジナル
783 人が閲覧しました

关于查询返回实体的问题
//实体类

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> class Newes   {   //var advertisingid;   //var adcontent;             private int advertisingid;        private String adcontent;        private String texttitle;        private String prclink;        private String time;        private String urllink;        private int newtype;        private String newlaiyuan;        public function getId()        {            return $this->advertisingid;        }        public function setId($advertisingid)        {            $this->advertisingid=$advertisingid;            return $this;        }        public function getAdcontent()        {            return $this->adcontent;        }        public function setAdcontent($adcontent)        {            $this->adcontent=$adcontent;            return $this;        }        public function getTexttitle()        {            return $this->texttitle;        }        public function setTexttitle($texttitle)        {            $this->texttitle=$texttitle;            return $this;        }       }
ログイン後にコピー

处理方法
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$sql="select * from newes where advertisingid =1";$abc =mysql_query($sql);/**while($num =mysql_fetch_array($abc)){    $num}*/
ログイン後にコピー

问:就是用什么方法返回一个实体类
比如 Newes $newes = new Newes();
$newes =mysql_query($sql); //这样子就是返回一个实体类么?
超级新手迷糊中····请帮忙解释一下 谢谢

------解决方案--------------------
两段代码之间有神马关系??
第一个返回实体类
第二个mysql_query返回resource类型的结果集
------解决方案--------------------
形如: private int advertisingid; 改为 private $advertisingid;

你那套是java里面的定义方法吧。
------解决方案--------------------
mysql_fetch_row()
mysql_fetch_array()
mysql_fetch_assoc()

具体区别,请谷歌查。
関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!