Jump to content

mdewyer

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Posts posted by mdewyer

  1. Thanks for the replies and input guys! I just wanted to clarify that the code I showed was "semi-pseudo" and I was just trying to better illustrate the question (faster to select through MySQL, or get PHP involved too). I wasn't too worried about the correctness of it, but I do appreciate the corrections anyhow :) And yeah, I understand that the "7" part of the INT has to do with the "display width" of the field with zero's and what not. Sorry for including that.

     

    I think with your feedback and some good planning, a db table should be able to handle this quite easily all by itself, and that's what I needed to know!

     

    Thanks!

  2. You might want to try using PHP's sort function (http://php.net/manual/en/function.sort.php) on the image array when it's created. Try putting

     

    sort($this->files_arr);

    right before the line

     

    $_SESSION['imgarr'] = $this->files_arr;

    Check out the "sort flags" parameter for the sort function if it's not quite sorting the way you'd like. Not sure if it'll work or not.

     

    Also, it looks like the gallery saves the file array to a session variable, so you'll probably have to clear your session to see the changes. That, or add the sorting to the code a few lines above that pulls from the session.

  3. If I follow you correctly, here's how I would do it:

     

    $result = mysql_query("SELECT A,B FROM USS");
    while ($row = mysql_fetch_assoc($result)) {
        $teste[] = '"' .$row['A']. ' ' .$row['B']. '"';
    }
    

  4. Say I have a MySQL table with two fields: "id" (primary key, INT(7)) and "hash" (indexed, VARCHAR(32)), and there will be hundreds of thousands of records in this table. Would it be faster / less CPU intensive to use MySQL to match both the id and hash fields to cleaned / sanitized request vars, or just match the id field with MySQL, and then use PHP to determine whether or not the hash is correct?

     

    So,

     

    mysql_query("SELECT * FROM table WHERE id='" .$id. "' AND hash=' .$hash. '");
    

    or:

     

    $query = mysql_query("SELECT * FROM table WHERE id='" .$id. "'");
    $row = mysql_fetch_assoc($query);
    if ($row['hash'] == $hash) ..
    

    One scenario you're requiring MySQL to match two things (the hash field would be 32 characters long, like a md5 string), the other way it would only have to find one field (a unique, primary key integer, which should be very fast), but MySQL would need to pull the data and put into an array that PHP can then read to determine if the other field is a match. I'm thinking the all-MySQL way would be faster, but I didn't know about it having to search through hundreds of thousands of records for a string of that size.

     

    Any thoughts? Thanks!

×
×
  • 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.