By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

$_SESSION : Speed-up MYSQL Frequent Results

P: n/a
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
Feb 21 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

Feb 22 '08 #2

P: n/a
On Fri, 22 Feb 2008 09:43:06 +0100, Pseudonyme
<no*************@2cuk.co.ukwrote:
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.
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
Feb 22 '08 #3

P: n/a

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]

Feb 22 '08 #4

P: n/a
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 :

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.
js*******@attglobal.net
==================

Feb 22 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.