pod_query

Mapping function to new function name (following normalization of function names from pod_ to pods_).

Description

pod_query( $sql, (string) $error = 'SQL failed', (constant) $results_error = null, (constant) $no_results_error = null ); 

Parameters (4)

0. $sql
The sql.
1. $error — Optional. (string) => 'SQL failed'
The error.
2. $results_error — Optional. (constant) => null
The results error.
3. $no_results_error — Optional. (constant) => null
The no results error.

Usage

  1. if ( !function_exists( 'pod_query' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/deprecated/deprecated.php'; 
  3.  
  4. // The sql. 
  5. $sql = null; 
  6.  
  7. // The error. 
  8. $error = 'SQL failed'; 
  9.  
  10. // The results error. 
  11. $results_error = null; 
  12.  
  13. // The no results error. 
  14. $no_results_error = null; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = pod_query($sql, $error, $results_error, $no_results_error); 
  18.  

Defined (1)

The function is defined in the following location(s).

/deprecated/deprecated.php  
  1. function pod_query ($sql, $error = 'SQL failed', $results_error = null, $no_results_error = null) { 
  2. pods_deprecated'pod_query', '2.0', 'pods_query'); 
  3. global $wpdb; 
  4.  
  5. $sql = trim($sql); 
  6. // Using @wp_users is deprecated! use $wpdb->users instead! 
  7. $sql = str_replace( '@wp_pod_tbl_', $wpdb->prefix . 'pods_', $sql ); 
  8. $sql = str_replace( '@wp_users', $wpdb->users, $sql ); 
  9. $sql = str_replace( '@wp_', $wpdb->prefix, $sql ); 
  10. $sql = str_replace( '{prefix}', '@wp_', $sql ); 
  11.  
  12. $sql = apply_filters( 'pod_query', $sql, $error, $results_error, $no_results_error ); 
  13.  
  14. // Return cached resultset 
  15. /**if ('SELECT' == substr($sql, 0, 6)) { 
  16. $cache = PodCache::instance(); 
  17. if ($cache->cache_enabled && isset($cache->results[$sql])) { 
  18. $result = $cache->results[$sql]; 
  19. if (0 < mysql_num_rows($result)) { 
  20. mysql_data_seek($result, 0); 
  21. $result = apply_filters('pod_query_return', $result, $sql, $error, $results_error, $no_results_error); 
  22. return $result; 
  23. }*/ 
  24.  
  25. if (false !== $error) 
  26. $result = mysql_query($sql, $wpdb->dbh) or die("<e>$error; SQL: $sql; Response: " . mysql_error($wpdb->dbh)); 
  27. else 
  28. $result = @mysql_query($sql, $wpdb->dbh); 
  29.  
  30. if (0 < @mysql_num_rows($result)) { 
  31. if (!empty($results_error)) 
  32. die("<e>$results_error"); 
  33. elseif (!empty($no_results_error)) 
  34. die("<e>$no_results_error"); 
  35.  
  36. if ('INSERT' == substr($sql, 0, 6)) 
  37. $result = mysql_insert_id($wpdb->dbh); 
  38. /**elseif ('SELECT' == substr($sql, 0, 6) && 'SELECT FOUND_ROWS()' != $sql) 
  39. $cache->results[$sql] = $result;*/ 
  40.  
  41. $result = apply_filters('pod_query_return', $result, $sql, $error, $results_error, $no_results_error); 
  42.  
  43. return $result;