vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   query_write clears all arrays??? (https://vborg.vbsupport.ru/showthread.php?t=226728)

raywjohnson 10-25-2009 02:34 AM

query_write clears all arrays???
 
Greetings All,

I am just plain missing something.

I am writing and admincp script. It gathers data from the post table, loops through it, and makes some changes base on what is found. I store some data in arrays. Then display a report of the scripts action. The script functions without error. But... if I have one query_write call, the arrays always return zero (0).

For example:
PHP Code:

  $array_ok $array_bad = array();
  
$data $db->query_read($query);
  while (
$rec $db->fetch_array($data)) {
    if(
some_test_here) {
      
$array_ok[]= $rec;
    } else {
      
$array_bad[]= $rec;
    }
  }

  echo 
count($array_ok) . ' -- ' count($array_bad);
-- 

This works as expected. Result: 21 -- 16 (i.e. the count() function returns proper count)

But, if I add just one query_write, the result is always: 0 -- 0 (i.e. the count() function returns 0 because the arrays are now empty)

All the query_read's/query_write's work as expected.

I even tried putting all queries for the query_write function in an array and loop through them at the end of the script. After the print_'s:
PHP Code:

  print_table_start();
  
print_table_header('test');
  
print_label_row('label',count($array_ok));
  
print_label_row('label',count($array_bad));
  
print_table_footer(1,'','',false);
 
  foreach(
$queries as $query) {
    echo(
"<pre>".preg_replace('! +!',' ',$query)." </pre>\n");
    
//$db->query_write($query);
  


This works as expected, but if I remove the //, the count() functions return 0.

--RayJ

--------------- Added [DATE]1256519837[/DATE] at [TIME]1256519837[/TIME] ---------------

Well... disregard. I change the script to a cron. Problem solved.

--RayJ


All times are GMT. The time now is 11:21 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01734 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete