Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:26+00:00 2026-05-28T00:09:26+00:00

I am doing some sql caching of certain queries. I’m using CakePHP so the

  • 0

I am doing some sql caching of certain queries. I’m using CakePHP so the query conditions are in an array thus:

array (
  0 => 
  array (
    0 => 'Tutorial.id IN ( SELECT tutorial_id FROM classifications WHERE classifications.product_id = 1 ) ',
  ),
  1 => 
  array (
    'Tutorial.status_id ' => 
    array (
      0 => 4,
      1 => 7,
    ),
  ),
  'OR' => 
  array (
    'Tutorial.user_id' => '40',
  ),
);

I’m mostly looking for the product_id, but there are some other possible conditions, so I wanted to reduce the array to a checksum and append it to the name of the cache file. This way I’d have tutorials_by_classification-413a86af or something, and I wouldn’t have to pick thru the array.

I’ve seen the function to implode mutli-d arrays on php.net in the comments, but I’m wondering if there’s a simpler way to achieve my goal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:09:27+00:00Added an answer on May 28, 2026 at 12:09 am

    How about serialize and md5? serialize creates a string representation of your array; md5 creates a hash of it.

    Example:

    $query = array (
      0 => 
      array (
        0 => 'Tutorial.id IN ( SELECT tutorial_id FROM classifications WHERE classifications.product_id = 1 ) ',
      ),
      1 => 
      array (
        'Tutorial.status_id ' => 
        array (
          0 => 4,
          1 => 7,
        ),
      ),
      'OR' => 
      array (
        'Tutorial.user_id' => '40',
      ),
    );
    
    $query_string = serialize($query);
    $hash = md5($query_string);
    
    echo $query_string, "\n\n\n", $hash, "\n";
    
    /*
    a:3:{i:0;a:1:{i:0;s:96:"Tutorial.id IN ( SELECT tutorial_id FROM classifications WHERE classifications.product_id = 1 ) ";}i:1;a:1:{s:19:"Tutorial.status_id ";a:2:{i:0;i:4;i:1;i:7;}}s:2:"OR";a:1:{s:16:"Tutorial.user_id";s:2:"40";}}
    
    
    a5cb59f0ee259961e426c7ce9b7b8f32
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster
I want to know how to retrieve results in a SQL query doing some
I am doing some performance tests using .Net 3.5 against SQL Server. I am
Just started a tutorial in SQL for beginners. I'm doing some exercises now and
I'm doing some basic sql on a few tables I have, using a union(rightly
I am doing some reporting on SQL Server jobs, using SQL Server Management Objects
I am doing some tests using the SQL 2005 profiler. I have a stored
im doing some practice sql problems one of the questions is: Prepare a shipping
I am doing some T-SQL programming and I have some Views defines on my
Does SQL Server 2005 maintain built-in, queryable, row-level last-modified timestamp metadata? I'm doing some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.