Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty Validate: Speed issues with Multi Dimensional Arrays

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
nsantos
Smarty n00b


Joined: 03 Dec 2004
Posts: 1

PostPosted: Mon Dec 20, 2004 3:09 am    Post subject: Smarty Validate: Speed issues with Multi Dimensional Arrays Reply with quote

I'm not sure if this is a smarty or smarty validate issue or even and issue at all? It seems that when running this piece of code it takes 5min or more to finish loading while pegging the server CPU and %100 utlz. Granted the $cells array has over 10000 elements in it.
[php:1:21abe4f0d3]
standingorder.tpl

<?php

{assign var="last" value=""}

{foreach from=$cells item=top}
{if $last != $top.0}
<tr>
<td colspan="{$cCount}" class="th">&</td>
</tr>
{/if}
{assign var="last" value=$top.0}
<tr>
{foreach from=$top item=mid}
{if $once != "1"}
{assign var="once" value="1"}
{else}
{validate form="standingOrderGrid" field=$mid.id criteria="isIntOrEmpty" message=$mid.id}
<td>{$mid.orderAmt}<input name="{$mid.id}" value="{$mid.qty}" type="text" size="3" maxlength="3" >
</td>
{/if}
{/foreach}
{assign var="once" value="0"}
</tr>
{/foreach}


?>[/php:1:21abe4f0d3]
But when I change the validate tag to,
[php:1:21abe4f0d3]<?php
{validate form="standingOrderGrid" field="$mid.id" criteria="isIntOrEmpty" message="$mid.id"}
?>[/php:1:21abe4f0d3]
,it runs fine but with out correct/working validation because the field that is trying to be validated is Array.id which is not correct because the field name should be the value of that element in the array.

Also I have used section tags in place of the foreach's and found little difference in speed. If anyone has found out different please let me know.

Below is the first full dimension of the $cells array. (Abbreviated for space) The outer array has 93 or so elements with the middle arrays having 58 elements or so and the inner arrays having 3 elements and will change depending on what is pulled from the database.
[php:1:21abe4f0d3]<?php
Array
(
[0] => Array
(
[0] => Breakfast Bagels
[1] => Array
(
[orderAmt] => 0
[qty] =>
[id] => 10105-82
)

[2] => Array
(
[orderAmt] => 0
[qty] =>
[id] => 10014-82
)

[57] => Array
(
[orderAmt] => 0
[qty] =>
[id] => 10021-82
)
?>[/php:1:21abe4f0d3]

So the question is:

A. What am I doing wrong?
B. Can what I'm trying to do be done? IE validate on the fly in the template using a multi dimensional array for data.
C. When and if will smarty/smarty validate handle multi dimensional arrays faster? From the info in the forums it seems smarty does not like going past 2 levels in arrays.
D. If not where can I start writing the code to fix it?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP