function Execute($zf_sql, $zf_limit = false, $zf_cache = false, $zf_cachetime = 0) { if ($zf_limit) { $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit; } $this->query = $zf_sql; $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @pg_query($this->link, $zf_sql); if (!$zp_db_resource) { $this->set_error(pg_last_error()); } $obj->resource = $zp_db_resource; $obj->cursor = 0; if ($obj->RecordCount() > 0) { $obj->EOF = false; $zp_result_array = @pg_fetch_array($zp_db_resource, NULL, PGSQL_ASSOC); if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { if (!preg_match('/^[0-9]/', $key)) { $obj->fields[strtolower($key)] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } } else { $obj->EOF = true; } $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; }
function Execute_return_error($zf_sql) { $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @mysql_query($zf_sql, $this->link); if (!$zp_db_resource) { $this->set_error(@mysql_errno($this->link), @mysql_error($this->link), false); } else { $this->set_error(0, '', false); // clear the error } $obj->resource = $zp_db_resource; $obj->cursor = 0; if ($obj->RecordCount() > 0) { $obj->EOF = false; $zp_result_array = @mysql_fetch_array($zp_db_resource); if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { if (!preg_match('/^[0-9]/', $key)) { $obj->fields[$key] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } } else { $obj->EOF = true; } $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; }
function ExecuteRandom($zf_sql, $zf_limit = 0, $zf_cache = false, $zf_cachetime = 0) { // if ($zf_limit) { // $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit; // } //echo $zf_sql . '<br />'; $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); $obj->result = array(); if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @pg_query($this->link, $zf_sql); if (!$zp_db_resource) { $this->set_error(pg_last_error()); } $obj->resource = $zp_db_resource; $obj->cursor = 0; $obj->Limit = $zf_limit; if ($obj->RecordCount() > 0) { $obj->EOF = false; $zp_Start_row = 0; if ($zf_limit) { $zp_start_row = zen_rand(0, $obj->RecordCount() - $zf_limit); } $obj->Move($zp_start_row); $obj->Limit = $zf_limit; $zp_ii = 0; while (!$obj->EOF) { $zp_result_array = @pg_fetch_array($zp_db_resource, NULL, PGSQL_ASSOC); if ($zp_ii == $zf_limit) { $obj->EOF = true; } if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { if (!ereg('^[0-9]', $key)) { // echo $key . '=' . $value . '<br />'; $obj->result[$zp_ii][$key] = $value; } } } else { $obj->Limit = $zp_ii; $obj->EOF = true; } $zp_ii++; } $obj->result_random = array_rand($obj->result, sizeof($obj->result)); // echo sizeof($obj->result) . " result array "; // print_r($obj->result); // echo '<br /><br />'; // echo 'random array '; // print_r($obj); if (is_array($obj->result_random)) { $zp_ptr = $obj->result_random[$obj->cursor]; } else { $zp_ptr = $obj->result_random; } while (list($key, $value) = each($obj->result[$zp_ptr])) { if (!ereg('^[0-9]', $key)) { $obj->fields[$key] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; }
function ExecuteRandomMulti($zf_sql, $zf_limit = 0, $zf_cache = false, $zf_cachetime = 0) { $this->zf_sql = $zf_sql; $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); $obj->result = array(); if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @mysql_query($zf_sql, $this->link); if (!$zp_db_resource) { $this->set_error(mysql_errno(), mysql_error()); } $obj->resource = $zp_db_resource; $obj->cursor = 0; $obj->Limit = $zf_limit; if ($obj->RecordCount() > 0 && $zf_limit > 0) { $obj->EOF = false; $zp_Start_row = 0; if ($zf_limit) { $zp_start_row = zen_rand(0, $obj->RecordCount() - $zf_limit); } $obj->Move($zp_start_row); $obj->Limit = $zf_limit; $zp_ii = 0; while (!$obj->EOF) { $zp_result_array = @mysql_fetch_array($zp_db_resource); if ($zp_ii == $zf_limit) { $obj->EOF = true; } if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { $obj->result[$zp_ii][$key] = $value; } } else { $obj->Limit = $zp_ii; $obj->EOF = true; } $zp_ii++; } $obj->result_random = array_rand($obj->result, sizeof($obj->result)); if (is_array($obj->result_random)) { $zp_ptr = $obj->result_random[$obj->cursor]; } else { $zp_ptr = $obj->result_random; } while (list($key, $value) = each($obj->result[$zp_ptr])) { if (!ereg('^[0-9]', $key)) { $obj->fields[$key] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; }
?> <h3 id="attribsOptionsText"><?php echo TEXT_PRODUCT_OPTIONS; ?> </h3> <?php } // END NON-SBA SPECIFIC: show please select unless all are readonly ?> <?php } // End display info ?> <?php if ($inSBA->EOF && $inSBA->RecordCount() < 1) { for ($I = 0; $I < sizeof($options_name); $I++) { ?> <?php if ($options_comment[$I] != '' and $options_comment_position[$I] == '0') { ?> <h3 class="attributesComments"><?php echo $options_comment[$I]; ?> </h3> <?php } // END h3_option_comment ?> <div class="wrapperAttribsOptions">
function Execute($zf_sql, $zf_limit = false, $zf_cache = false, $zf_cachetime = 0) { global $zc_cache; if ($zf_limit) { $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit; } if ($zf_cache and $zc_cache->sql_cache_exists($zf_sql) and !$zc_cache->sql_cache_is_expired($zf_sql, $zf_cachetime)) { $obj = new queryFactoryResult(); $obj->cursor = 0; $obj->is_cached = true; $obj->sql_query = $zf_sql; $zp_result_array = $zc_cache->sql_cache_read($zf_sql); $obj->result = $zp_result_array; if (sizeof($zp_result_array) > 0) { $obj->EOF = false; while (list($key, $value) = each($zp_result_array[0])) { $obj->fields[$key] = $value; } return $obj; } else { $obj->EOF = true; } } elseif ($zf_cache) { $zc_cache->sql_cache_expire_now($zf_sql); $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); $obj->sql_query = $zf_sql; if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @mysql_query($zf_sql, $this->link); if (!$zp_db_resource) { $this->set_error(@mysql_errno(), @mysql_error()); } $obj->resource = $zp_db_resource; $obj->cursor = 0; $obj->is_cached = true; if ($obj->RecordCount() > 0) { $obj->EOF = false; $zp_ii = 0; while (!$obj->EOF) { $zp_result_array = @mysql_fetch_array($zp_db_resource); if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { if (!preg_match('/^[0-9]/', $key)) { $obj->result[$zp_ii][$key] = $value; } } } else { $obj->Limit = $zp_ii; $obj->EOF = true; } $zp_ii++; } while (list($key, $value) = each($obj->result[$obj->cursor])) { if (!preg_match('/^[0-9]/', $key)) { $obj->fields[$key] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } $zc_cache->sql_cache_store($zf_sql, $obj->result); $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; } else { $time_start = explode(' ', microtime()); $obj = new queryFactoryResult(); if (!$this->db_connected) { $this->set_error('0', DB_ERROR_NOT_CONNECTED); } $zp_db_resource = @mysql_query($zf_sql, $this->link); if (!$zp_db_resource) { $this->set_error(@mysql_errno($this->link), @mysql_error($this->link)); } $obj->resource = $zp_db_resource; $obj->cursor = 0; if ($obj->RecordCount() > 0) { $obj->EOF = false; $zp_result_array = @mysql_fetch_array($zp_db_resource); if ($zp_result_array) { while (list($key, $value) = each($zp_result_array)) { if (!preg_match('/^[0-9]/', $key)) { $obj->fields[$key] = $value; } } $obj->EOF = false; } else { $obj->EOF = true; } } else { $obj->EOF = true; } $time_end = explode(' ', microtime()); $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0]; $this->total_query_time += $query_time; $this->count_queries++; return $obj; } }