小编Mon*_*eed的帖子

查询中的PHP vs MySQL性能(如果,函数)

我只看到这个艺术品

在这种情况下,我需要知道什么是最佳的绩效

如果在查询中的陈述

SELECT *,if( status = 1 , "active" ,"unactive") as status_val FROM comments

VS

<?php
    $x = mysql_query("SELECT * FROM comments");

     while( $res = mysql_fetch_assoc( $x ) ){
       if( $x['status'] == 1 ){
             $status_val = 'active';
        }else{
             $status_val = 'unactive';
        }
     }
  ?>
Run Code Online (Sandbox Code Playgroud)

从字符串切10

SELECT * , SUBSTR(comment, 0, 10) as min_comment FROM comments

VS

<?php
    $x = mysql_query("SELECT * FROM comments");

     while( $res = mysql_fetch_assoc( $x ) ){
       $min_comment = substr( $x['comment'],0,10 ) ;
     }
  ?> …
Run Code Online (Sandbox Code Playgroud)

php mysql performance benchmarking

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

Mysql:每只猫获得2个结果[一对多关系]

我正在寻找获得结果的最佳方法,数据库包含超过100000 Post和超过100000 Cat

这是我的桌子

-----------------
-  id   | name  |
-----------------
-  1    | x     |
-----------------
-  2    | y     |
-----------------
Run Code Online (Sandbox Code Playgroud)

岗位

--------------------------------------
-  id   | cat_id | title  | content  |
--------------------------------------
-  1    | 1      | Post 1 | .. . .  .|
--------------------------------------
-  2    | 1      | Post 2 | . . . . .|
--------------------------------------
-  3    | 2      | Post 3 | .. . .  .|
--------------------------------------
-  4    | 1 …
Run Code Online (Sandbox Code Playgroud)

mysql sql performance join

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

curl:由于 CloudFlare,无法从网站获取 rss

我值得注意的是在服务器上使用 curl连接这个站点http://www.youm7.com/newtkarirrss.asp

但我可以从本地主机访问它没有任何问题

这是测试

http://www.tjreb.com/xml_grabber.php?feed=http://www.youm7.com/newtkarirrss.asp&stack=1

试试 CNN RSS 提要

http://www.tjreb.com/xml_grabber.php?feed=http://rss.cnn.com/rss/edition_meast.rss&stack=0

我怎样才能绕过这个错误

这是我的源代码

<?php
  class xml_grabber
        {
            private $xml_file       = '' ;
            private $xml_link       = '' ;
            private $xml_dom        = '' ;
            private $xml_type       = '' ;
            private $xml_content    = '' ;
            private $xml_errors     = array() ;
            public  $xml_stack      = 0  ;

            public function __construct($link_file_com = '')
                   {
                       if(!$link_file_com)
                            {
                              $this->xml_errors['construct'] = 'No Xml In Construct' ;
                              return false;
                            }
                       elseif(!function_exists('simplexml_load_file') || !function_exists('simplexml_load_string') || !function_exists('simplexml_import_dom'))
                            {
                              $this->xml_errors['functions'] = …
Run Code Online (Sandbox Code Playgroud)

php xml-parsing rss-reader cloudflare

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

mysql获得结果的最佳方式

这是我的表格

注意 此表仅供参考

帖子

++++++++++++++++++++++++++++++++++++++++
+   id  |title | desc  |  uid  |status |
++++++++++++++++++++++++++++++++++++++++
+   1   |  a   | aaaa  |   1   |   1   |
++++++++++++++++++++++++++++++++++++++++
+   2   |  b   | bbbb  |   1   |   1   |
++++++++++++++++++++++++++++++++++++++++
+   3   |  c   | cccc  |   2   |   1   |
++++++++++++++++++++++++++++++++++++++++
Run Code Online (Sandbox Code Playgroud)

+++++++++++++++++++++++++++++++++
+  id   | name |parent | status |
+++++++++++++++++++++++++++++++++
+  1    | cat1 |   0   |   1    |
+++++++++++++++++++++++++++++++++
+  2    | cat2 |   0   |   1 …
Run Code Online (Sandbox Code Playgroud)

php mysql performance

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