ホームページ  >  記事  >  バックエンド開発  >  クエリによって返されるエンティティに関する質問

クエリによって返されるエンティティに関する質問

WBOY
WBOYオリジナル
2016-06-13 13:33:16803ブラウズ

クエリで返されたエンティティに関する質問
//エンティティクラス

PHPコード
<!--

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 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
}
*/


質問:エンティティクラスを返すにはどのようなメソッドを使用しますか?
超初心者が混乱しています...説明を手伝ってください、ありがとう


------解決策------ - --
2 つのコードの間には何か関係がありますか? ? 最初のクエリはエンティティ クラスを返します
2 番目の mysql_query はリソース タイプの結果セットを返します

------解決策------------------
次のようになります: private intadvertisingid; が private $advertisingid;
に変更されました。おそらく、このメソッドは Java の定義メソッドです。

------解決策---------
mysql_fetch_row()mysql_fetch_array()
mysql_fetch_assoc()

具体的な違いについては、Google で確認してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。