Jump to content

vintox

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

vintox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Andy123, the last 2 examples works and do the job but the consume a lot of memory and processing time. foreach is a better way to work with arrays. but with foreach is like it checks if its the end of the array before it executes the code inside
  2. $views++ first place the value inside the string after that it increments it. do it like this: ++$views or $nViews = $views++ "UPDATE page_views2 SET views = $nViews WHERE institute_id = $institute_id";
  3. i have a foreach statement which looks like this foreach(static::$_components as &$field){ ..some code } in "some code" i sometimes add more components to "static::$_components" member if the insertion happens not at the final iteration it works, and the foreach detect & use the last insertion. but if the insertion happens at the last iteration the foreach statement breaks(ends) without detecting & using the last insertion there is any workaround for this issue beside using for loops and count(array). i prefer using foreach due to performance demands for($iterator = 0, $field = ''; null != ($field = empty(static::$_components[$iterator]) ? null : static::$_components[$iterator]); $iterator++){ ...some code } consumes a lot of memory and proccessing time using for($iterator = 0; $iterator < count(static::$_components); $iterator++){ ...some code } is even worse Thanks in advance
  4. the assigning occurs at the controller. after the assigning i am executing View::render($data); there i am doing extract. the second method skips the assigning to a variable and the extracting by the view class and execute the pageFooter method so logically it should use less memory you mentioned the different times i am executing pageFooter. if i use memory_get_peak_usage() is it still matter?
  5. using memory_get_peak_usage() gives the same results as memory_get_usage when i use "pageFooter" method. returns 108kb if i use memory_get_usage(true)/memory_get_peak_usage(true) i get 256kb even if i add code to my script still returns 256kb
  6. I am developing a system using the MVC design pattern. for debugging & optimizing the script i am using memory_get_usage() at the Start and the End of the script. i have a file footer.html.php if the file looks like this <?= $bodyContent ?> by using extract with $bodyContent = \Views\General_View::pageFooter(); the script consume 76kb of memory. but if i change footer.html.php to <?= \Views\General_View::pageFooter() ?> the script consume 108kb of memory. pageFooter method is: static public function pageFooter() { $str = '<br /><br />'.Converter::memorySizeConverter($b = memory_get_usage()). ' ('.Converter::memorySizeConverter($b-SCRIPT_START_MEMORY).')'; $end = microtime(true); $str .= '<br />Processing time: '. sprintf('%.4f', ($end-SCRIPT_START_TIME)).' seconds'; return $str; }
  7. i am trying to do a full join for 3 tables i know how to make full join for 2 tables using left,right joins and union all but when i tried to join the third table i got some errors i tried this one: SELECT gcap,tcap FROM (SELECT type.caption as tcap,genre.caption as gcap FROM type LEFT JOIN genre ON type.id = genre.id UNION SELECT type.caption as tcap,genre.caption as gcap FROM type RIGHT JOIN genre ON type.id = genre.id WHERE type.id IS NULL )a LEFT JOIN category ON category.id = type.id Any help is welcome Thanks in advance Vintox
  8. there is a way to combine multiple counts or sum from multiple tables? i tried this query but it returns the last "count(r.id)" for all of the three SELECT COUNT(m.id) as unum,COUNT(p.id) as pnum, COUNT(r.id) as rnum FROM members as m, posts as p, reply as r
  9. maybe this query would work: SELECT * FROM `report_hours` WHERE (start_date>'2009-04-01' && start_date<'2009-05-08') OR (end_date>'2009-04-01' && end_date<'2009-05-08')
  10. the group By is for the right and left joins the WHERE is for the union i looked at this article and tried to build a query for my needs http://en.wikipedia.org/wiki/Join_%28SQL%29#Full_outer_join
  11. #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE rcount=0 LIMIT 0, 30' at line 10
  12. 1.In reply table the is a reply field 2.I am using UNION on the same SQL because Mysql doesn't have an option of using FULL OUTER JOIN 3.even if i use WHERE rcount=0 or trying COUNT(reply)=0 i get syntax error
  13. I am trying to make a full join query i found some simulating methods for simulating full join but when i am using simulating and the selection is a grouping value like count() i am getting a syntax error the query is going like this: SELECT p.*,COUNT(reply) as rcount FROM reply r LEFT OUTER JOIN posts p ON p.id = r.post GROUP BY r.post UNION SELECT p.*,COUNT(reply) as rcount FROM reply r RIGHT OUTER JOIN posts p ON p.id = r.post GROUP BY r.post WHERE COUNT(reply) IS NULL Thanks in advance vintox
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.