$_SESSION : Speed-up MYSQL Frequent Results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pseudonyme

    $_SESSION : Speed-up MYSQL Frequent Results

    Dear Sirs and Madams,

    Receive as information that storing a MYSQL result under $_SESSION was
    accelerating web page displays processes ? Absolutly needed but
    impossible to get this working !

    I try, but do not succeed in implement $_SESSION with MYSQL.

    <?php
    session_start() ;
    include_once("c onnector.php");


    $cerise=$_REQUE ST['cerise'];
    $raisin=$_REQUE ST['raisin'];


    $rsstatus = getVignoble("ps .cerise_id=$cer ise and b.raisin_id
    $raisin");

    // getVignoble is a fonction Select a status for #cerise and #raison
    from a table

    if(isset($_SESS ION['status'])) {
    $_SESSION['status']=$rsstatus;
    $bob=$_SESSION['status'];
    echo 'case 1 <br>';



    } else {


    $rsstatus = getVignoble("ps .cerise_id=$cer ise and b.raisin_id
    $raisin");
    $bob=$_SESSION['status'];
    echo 'case 2 <br>';


    }


    // Result is A. I would like to get that A stored, that would avoid
    making a second time the MySQL query.


    // I try that that works, but still, I believe that does the query and
    that does not use the $_SESSION system :
    echo $bob[0]['status'];


    // That one Unfortunatly does not work : I would have believed the
    contrary :
    $_SESSION[0]['status']


    // That one ask the Array :
    $_SESSION['status']


    // But the session is launched:
    $_SESSION['myName'] = 'bpat1434';
    echo '<br><br>My Name Is (session set): ' . $_SESSION['myName'];
    ?>

    Do you know how to use $_SESSION as $_SESSION[0]['status'] in that
    e.g.

    Thank you very much for your knowleadge and experience.

    cougloff


  • Pseudonyme

    #2
    Re: $_SESSION : Speed-up MYSQL Frequent Results

    Hi Rick,
    Thank you for your answer,

    function getVignoble ($filtres){
    $sql="SELECT ps.status as status, ps.Cepageas Cepage from
    Tbl_Raisin_Prog ram_Status ps, Tbl_Creative_In formation b where
    b.Cepage= ps.Cepage and $filtres";
    return select_query($s ql);

    }

    The function getVignoble is returning the status of :
    $cerise=$_REQUE ST['cerise'];
    $raisin=$_REQUE ST['raisin'];

    in Table Tbl_Raisin_Prog ram_Status comparing Cerise and Cepage.

    To get the Cepage value, I have to find it through the
    Tbl_Creative_In formation.

    As a result the cross check between Cerise and Raisin is wether 'A'
    for an accepted mix or 'R' for a rejected mix.

    Cannot find how to store within the session the 'A' value under an as-
    is function : $_SESSION[0]['status']
    That $_SESSION[0]['status'] does not work.

    Thanks, many thanks for your help.

    cougloff

    Comment

    • Rik Wasmus

      #3
      Re: $_SESSION : Speed-up MYSQL Frequent Results

      On Fri, 22 Feb 2008 09:43:06 +0100, Pseudonyme
      <norman_couglof f@2cuk.co.ukwro te:
      Hi Rick,
      Thank you for your answer,
      >
      function getVignoble ($filtres){
      $sql="SELECT ps.status as status, ps.Cepageas Cepage from
      Tbl_Raisin_Prog ram_Status ps, Tbl_Creative_In formation b where
      b.Cepage= ps.Cepage and $filtres";
      return select_query($s ql);
      >
      }
      And once again select_query() is a custom function of which I don't know
      what kind of return it gives, do a var_dump() on the return of
      getVignoble() (whithout any senseitive data offcourse, just the type of
      data will suffice).

      Also, how often does data change? People hate to log out and in the see
      any change in it. If the query takes to long, you probably want to use
      proper indexing in the database to speed it up before using just an extra
      storage/cache. Run the queries with an explain, see if you can make them
      more efficient, ask in a MySQL group if you don't know how.
      Cannot find how to store within the session the 'A' value under an as-
      is function : $_SESSION[0]['status']
      That $_SESSION[0]['status'] does not work.
      Store them under a name rather then a number (see more of the session
      manual):
      $_SESSION['some_name_that _would_be_a_val id_variable_nam e']['status'] ='';
      --
      Rik Wasmus

      Comment

      • Pseudonyme

        #4
        Re: $_SESSION : Speed-up MYSQL Frequent Results


        Hi Rick,

        We have some development to be made to optimize our PHP/MySQL
        configuration.

        Trying to make of list of optimization leads to that first points :



        We are searching a PHP/MySQL expert that would implement best-of-
        practices on our PHP/MySQL configuration.

        5 PHP.files are linked to 5 MySQL.tables requested thousands of time/
        day.

        There is especially one file of 15 PHP.lines and 1 MySql.table of 3
        columns that generate 80% of the all traffic.

        Would you or a Php/MySQl expert you know, be interested in optimizing
        this PHP/MySql config. ?

        cougloff




        ......



        Add [17] : Instead of PHP. rewriting could be an optimization in some
        cases.
        RewriteEngine on
        RewriteBase /
        RewriteCond %{HTTP_HOST} ^www.yourdomain .com$
        RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]





        Comment

        • Jerry Stuckle

          #5
          Re: $_SESSION : Speed-up MYSQL Frequent Results

          Pseudonyme wrote:
          Hi Rick,
          >
          We have some development to be made to optimize our PHP/MySQL
          configuration.
          >
          Trying to make of list of optimization leads to that first points :
          >

          >
          We are searching a PHP/MySQL expert that would implement best-of-
          practices on our PHP/MySQL configuration.
          >
          5 PHP.files are linked to 5 MySQL.tables requested thousands of time/
          day.
          >
          There is especially one file of 15 PHP.lines and 1 MySql.table of 3
          columns that generate 80% of the all traffic.
          >
          Would you or a Php/MySQl expert you know, be interested in optimizing
          this PHP/MySql config. ?
          >
          cougloff
          >
          >
          >
          >
          .....
          >
          >
          >
          Add [17] : Instead of PHP. rewriting could be an optimization in some
          cases.
          RewriteEngine on
          RewriteBase /
          RewriteCond %{HTTP_HOST} ^www.yourdomain .com$
          RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
          >
          >
          >
          >
          >
          >
          First of all, start with your MySQL optimization. Ask in
          comp.databases. mysql.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          Working...