Connecting Tech Pros Worldwide Help | Site Map

$_SESSION : Speed-up MYSQL Frequent Results

Pseudonyme
Guest
 
Posts: n/a
#1: Feb 21 '08
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("connector.php");


$cerise=$_REQUEST['cerise'];
$raisin=$_REQUEST['raisin'];


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

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

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



} else {


$rsstatus = getVignoble("ps.cerise_id=$cerise 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
Guest
 
Posts: n/a
#2: Feb 22 '08

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_Program_Status ps, Tbl_Creative_Information b where
b.Cepage= ps.Cepage and $filtres";
return select_query($sql);

}

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

in Table Tbl_Raisin_Program_Status comparing Cerise and Cepage.

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

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

Rik Wasmus
Guest
 
Posts: n/a
#3: Feb 22 '08

re: $_SESSION : Speed-up MYSQL Frequent Results


On Fri, 22 Feb 2008 09:43:06 +0100, Pseudonyme
<norman_cougloff@2cuk.co.ukwrote:
Quote:
Hi Rick,
Thank you for your answer,
>
function getVignoble ($filtres){
$sql="SELECT ps.status as status, ps.Cepageas Cepage from
Tbl_Raisin_Program_Status ps, Tbl_Creative_Information b where
b.Cepage= ps.Cepage and $filtres";
return select_query($sql);
>
}
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.
Quote:
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_valid_variable_name']['status'] ='';
--
Rik Wasmus
Pseudonyme
Guest
 
Posts: n/a
#4: Feb 22 '08

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 :

http://groups.google.com/group/comp....7a2801ef1ced4e

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]





Jerry Stuckle
Guest
 
Posts: n/a
#5: Feb 22 '08

re: $_SESSION : Speed-up MYSQL Frequent Results


Pseudonyme wrote:
Quote:
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 :
>
http://groups.google.com/group/comp....7a2801ef1ced4e
>
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@attglobal.net
==================

Closed Thread