小编rav*_*dev的帖子

使用simplexml_load_file解析XML文件将返回空对象

 <?xml version="1.0" ?> 
  <aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/">
   <aws:Response xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11">
    <aws:OperationRequest>
    </aws:OperationRequest>
    <aws:UrlInfoResult>
     <aws:Alexa>
      <aws:TrafficData>
       <aws:DataUrl type="canonical">google.com/</aws:DataUrl> 
       <aws:Rank>1</aws:Rank> 
      </aws:TrafficData>
     </aws:Alexa>
    </aws:UrlInfoResult>
    <aws:ResponseStatus xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/">
     <aws:StatusCode>Success</aws:StatusCode> 
    </aws:ResponseStatus>
   </aws:Response>
  </aws:UrlInfoResponse>
Run Code Online (Sandbox Code Playgroud)

我要解析的是这个xml文档的排名.在尝试的同时,我正在做的是......

        $xml= simplexml_load_file("path of the file saved");
        echo $xml->Response->UrlInfoResult->Alexa->TrafficData->Rank;
Run Code Online (Sandbox Code Playgroud)

但我这样做是错误的.比如说

 Notice: Trying to get property of non-object in C:\wamp\www\SEO Stats[Only Testing]\Tools\web_worth.php on line 13
Run Code Online (Sandbox Code Playgroud)

错误就在这一行

 echo $xml->Response->UrlInfoResult->Alexa->TrafficData->Rank;
 this line is referred as line no 13..
Run Code Online (Sandbox Code Playgroud)

php xml simplexml

3
推荐指数
1
解决办法
1万
查看次数

在CakePHP中以1更新一行

我搜索了这个问题,发现了很多类似的答案

在CakePHP中更新+1行

这就是公认的答案

$ this-> Widget-> updateAll(

      array('Widget.numberfield' => 'Widget.numberfield + 1'),

      array('Widget.id' => 1)
Run Code Online (Sandbox Code Playgroud)

);

现在,iam在cakephp3中使用此查询。这是我的样子

$ Questions = $ this-> loadModel('Questions');

$问题-> updateAll(

       array('questions.trend' => 'questions.trend + 1'),

       array('questions.description' => $undashed_title)
Run Code Online (Sandbox Code Playgroud)

);

一切正常,查询正在执行,但是当我检查调试器的sql日志时,这就是我发现的内容

更新问题,请设置questions.trend ='questions.trend + 1',而where Problems.description ='哪种类型

但是我在数据库中的值没有像应有的那样更新(我说这是因为我也已经在phpmyadmin控制台上复制了此查询,并且无法正常工作)

我相信查询应该看起来像这样

更新问题SETquestions.trend = questions.trend + 1 WHEREquestions.description ='What Type'

任何帮助,将不胜感激,谢谢:)

php mysql cakephp cakephp-model cakephp-3.0

1
推荐指数
1
解决办法
778
查看次数

标签 统计

php ×2

cakephp ×1

cakephp-3.0 ×1

cakephp-model ×1

mysql ×1

simplexml ×1

xml ×1