Re: [fw-general] Zend_Layout with nested layout?

2008-03-08 Thread Christian Ehmig



 
 I'm just playing with Zend_Layout and have a quick question. What I'd  
 like to do is have a three part view. I'd like my designer to design a  
 wrapper template that consists of the markup surrounding the output  
 of action views. This is exactly what Zend_Layout does so perfect! but  
 if possible I'd like the designer templates to exclude the doctype,  
 head and html and body tag stuff and stick strictly to what comes  
 after body.  That way designers don't need to worry about the non-
 design stuff.
 
 doc.phtml:
 
 !DOCTYPE html
  PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html
 head
  meta http-equiv=Content-Type content=text/html;  
 charset=utf-8 /
  title?= $this-headTitle() ?/title
  ?= $this-headScript() ?
  ?= $this-headStyle() ?
 /head
 body
 ?= $this-layout()-content ?
 /body
 /html
 
 which includes the following designer layout.phtml in content:
 
 div id=content
 !-- renders /nav/menu --
 div id=nav?= $this-layout()-nav ?/div
 !-- renders /foo/index + /comment/fetch --
 div id=content?= $this-layout()-content ?/div
 /div
 
 which includes the action.phtml template in content. 
 


You could probably create a view helper like this:

class My_View_Helper_NestedLayout
{   
  
public function nestedLayout($layoutName)
{
try { 
$layout = Zend_Layout::getMvcInstance();

echo $layout-render($layoutName);
}
} catch (Zend_Exception $e) {
$this-view-layout($layoutName);
}
}   

public function setView(Zend_View_Interface $view)
{
$this-view = $view;
}
}

add the helper path (see
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.custom)

Usage in your main layout (doc.phtml):

...
?  $this-nestedLayout('content/layout') ?   
...

this would render the layout file 'content/layout.phtml' (relative to your
layout path) at the position where like to render the content.


Please correct me if this might fail in any case!
-- 
View this message in context: 
http://www.nabble.com/Zend_Layout-with-nested-layout--tp15878224s16154p15912857.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_DB performance issue

2007-12-10 Thread Christian Ehmig

Yes, I noticed that my request is already listed in the issue tracker -
unfortunately after I wrote my post :)

Btw, I recommend to disable the preparing of sql statements for the MySQL
Adapters by default.



Darby Felton wrote:
 
 Christian Ehmig wrote:
 Hi!
 
 Some time ago I noticed that Zend_DB and especially
 Zend_Db_Adapter_Abstract
 prepare ANY statement except when you use the following code fragment:
 
 $result = $db-getConnection()-exec('DROP TABLE bugs');
 
 The methodology of preparing each statement is necessary for Oracle as
 far
 as I remember. Regarding MySQL it has a huge impact on performance
 instead!
 The one and only time you need to prepare a statement in MySQL is if you
 use
 the prepared query several times with different values bound to the ?
 parameters. 
 
 I compared the Zend:DB MySQL adapters to ADO, Pear and Native PHP code
 inserting 100.000 rows.
 
 Code looked something like this:
 
 for ($i = 0; $i  100.000; $i++) {
 
 $data = array(
 'text' = 'somedummytext'
 );
 
 $db-insert('testtable', $data);
 }
 
 Now, the Zend MySQL adapters send 200.000 queries to the mysql server in
 this case, a prepare  execute for each call to $db-insert().
 
 This resulted in double execution time compared to native php access in
 other words a performance drop of 100%! Of course, SELECT statements
 (fetchRow, fetchAll, etc.) are prepared, too. Just imagine you use around
 100 select queries to render a site - each select will be individually
 prepared, although this is completely nonsense in my opinion.
 
 Are there any plans for disabling the automatic prepare feature or any
 other hints on this issue?
 
 Yes, actually, this is a known issue and planned to be completed soon:
 
 http://framework.zend.com/issues/browse/ZF-1398
 
 Please feel free to jump in and contribute!
 
 http://framework.zend.com/community/contribute
 
 Best regards,
 Darby
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_DB-performance-issue-tp14233508s16154p14255161.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_DB performance issue

2007-12-08 Thread Christian Ehmig

Hi!

Some time ago I noticed that Zend_DB and especially Zend_Db_Adapter_Abstract
prepare ANY statement except when you use the following code fragment:

$result = $db-getConnection()-exec('DROP TABLE bugs');

The methodology of preparing each statement is necessary for Oracle as far
as I remember. Regarding MySQL it has a huge impact on performance instead!
The one and only time you need to prepare a statement in MySQL is if you use
the prepared query several times with different values bound to the ?
parameters. 

I compared the Zend:DB MySQL adapters to ADO, Pear and Native PHP code
inserting 100.000 rows.

Code looked something like this:

for ($i = 0; $i  100.000; $i++) {

$data = array(
'text' = 'somedummytext'
);

$db-insert('testtable', $data);
}

Now, the Zend MySQL adapters send 200.000 queries to the mysql server in
this case, a prepare  execute for each call to $db-insert().

This resulted in double execution time compared to native php access in
other words a performance drop of 100%! Of course, SELECT statements
(fetchRow, fetchAll, etc.) are prepared, too. Just imagine you use around
100 select queries to render a site - each select will be individually
prepared, although this is completely nonsense in my opinion.

Are there any plans for disabling the automatic prepare feature or any
other hints on this issue?





-- 
View this message in context: 
http://www.nabble.com/Zend_DB-performance-issue-tp14233508s16154p14233508.html
Sent from the Zend Framework mailing list archive at Nabble.com.