Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework 条令1.2嵌套集非常慢。如何改进它。(嵌套集)_Zend Framework_Nested Sets_Doctrine 1.2 - Fatal编程技术网

Zend framework 条令1.2嵌套集非常慢。如何改进它。(嵌套集)

Zend framework 条令1.2嵌套集非常慢。如何改进它。(嵌套集),zend-framework,nested-sets,doctrine-1.2,Zend Framework,Nested Sets,Doctrine 1.2,我使用原则1.2执行一个简单的查询 这是问题所在 $cat = Doctrine_Core::getTable('Model_Category')->find($CatID); if( isset($cat) && $cat->getNode()->hasChildren()) $this->view->CategoryTree = $cat->getNode()->getChildren(); 为什么这么慢

我使用原则1.2执行一个简单的查询

这是问题所在

$cat = Doctrine_Core::getTable('Model_Category')->find($CatID);
if( isset($cat) && $cat->getNode()->hasChildren())
            $this->view->CategoryTree = $cat->getNode()->getChildren();
为什么这么慢


任何人都有一个解决方案来获得更好的性能。

谢谢

当我对我的应用程序进行基准测试时,我发现使用Doctrine_Core::Hydroid_数组带来了很大的不同。当仅在视图中使用时,这通常是有意义的

如果您需要更复杂的嵌套集,只使用Doctrine_查询可能是更好的选择

您可能需要这样的查询:

$query = Doctrine_Query::create();
$query->from('Model_Category cat')
    ->leftJoin('cat.Node n')
    ->leftJoin('n.Childre c')
    ->where('count(c.id) > 0')
    ->andWhere('cat.id = ?', $id);
$query->execute(array(1), Doctrine_Core::HYDRATE_ARRAY)
如果您使用Ubuntu,Xdebug评测会非常有用:

sudo apt get安装php5 xdebug

然后:

sudo gedit/etc/php5/apache2/conf.d/xdebug.ini

在xdebug.ini中,我有:

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.profiler_enable=on
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%H.%R.%t"
请记住创建目录:

mkdir/tmp/xdebug

sudo chgrp www.data/tmp/xdebug

chmod 774/tmp/xdebug


然后我使用KCachegrind查看输出,希望这有助于

当我对我的应用程序进行基准测试时,我发现使用Doctrine_Core::水合物_数组产生了很大的不同。当仅在视图中使用时,这通常是有意义的

如果您需要更复杂的嵌套集,只使用Doctrine_查询可能是更好的选择

您可能需要这样的查询:

$query = Doctrine_Query::create();
$query->from('Model_Category cat')
    ->leftJoin('cat.Node n')
    ->leftJoin('n.Childre c')
    ->where('count(c.id) > 0')
    ->andWhere('cat.id = ?', $id);
$query->execute(array(1), Doctrine_Core::HYDRATE_ARRAY)
如果您使用Ubuntu,Xdebug评测会非常有用:

sudo apt get安装php5 xdebug

然后:

sudo gedit/etc/php5/apache2/conf.d/xdebug.ini

在xdebug.ini中,我有:

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.profiler_enable=on
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%H.%R.%t"
请记住创建目录:

mkdir/tmp/xdebug

sudo chgrp www.data/tmp/xdebug

chmod 774/tmp/xdebug


然后我用KCachegrind查看输出,希望这有帮助

谢谢Max,你为我节省了很多时间。谢谢Max,你为我节省了很多时间。