473,809 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_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
Feb 21 '08 #1
4 2052
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

Feb 22 '08 #2
On Fri, 22 Feb 2008 09:43:06 +0100, Pseudonyme
<no************ *@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
Feb 22 '08 #3

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
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*******@attgl obal.net
=============== ===

Feb 22 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2602
by: Thomas Carcaud | last post by:
I read php manual many times but I can't figure out register_globals works. I m using Php 4.3.2 and register_globals on. It seems to have different effects on $_GET and $_SESSION. First with $_GET : <? echo $var."\n"; echo $_GET."\n"; $var="gna"; echo $var."\n"; echo $_GET."\n"; $_GET="gnou";
5
10920
by: Rob Tweed | last post by:
Probably a simple question but I can't find the answer anyway. Specifically, is it possible to copy a multidimensional array into the $_SESSION array - ie a deep clone of all keys and data? I naively assumed that $_SESSION = $myArray ; would work but it doesn't appear to work. Is there a single function
6
4552
by: Antoni | last post by:
Hello all, I wondered if anyone could offer me some guidance, I wrote this script using the dzsoft php editor, which links to php.exe and a internal server. Though when I run the code the session files are created, but the item number in the files never increase beyond (0). I just wondered if there was anyone options in the php.ini I could
12
41198
by: Michael Windsor | last post by:
I've been trying to integrate some PHP pages of my own with some existing code. The details of this are for the support forums for that code (where I have been asking questions), but I wonder if someone here can enlighten me as to why the problematic code is having the effect it is. For reasons I don't know, if the PHP version is 5 or greater, register_long_arrays is false and $_SESSION exists, the following statement is executed: ...
1
1518
by: moho | last post by:
Hi I'm trying to use $_SESSION in my AJAX application. However this gives me strange data, the $_SESSION variable seems to change during page load. in the end of the page it's the earlier value that shows. I set the $_SESSION with this function setId(id) { try{ var obj;
2
1822
by: somecrazyguy | last post by:
Take the following code, one would think that there was absolutely no link between $test and $_SESSION. But if you reload the page, guess what... "After=FAILED". Why? Because for some reason, writing to $test affects the $_SESSION variable $_SESSION. session_start(); ini_set("session.gc_maxlifetime","3600"); if ($_REQUEST == "1") session_unset(); var_dump($_SESSION); if (!$_SESSION) $_SESSION = "Test"; echo...
4
2349
by: dpinion | last post by:
Greetings, I am trying to do some simple session stuff. However it does not seem as though the session variable is being created for my site. I am running the latest version of PHP and apache that I installed as part of WAMP. Machine is XP SP2. Basically I am trying to do something simple such as: <?php
8
3371
by: SpiritBreaker | last post by:
I am having problems getting the $_SESSION to set, the $_SESSION will work fine when its first gets the value, however, when I go to another page, the $_SESSION then loses its value. So if any one can take a look at my code and see if there is any problems, that would be good. Thanks Here is my code <?php if (!isset($_SESSION)) session_start();
2
2268
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session variable for each item as its clicked, and increment the value held by the session variable by 1 each time that item is clicked. My plan was to allow an item to be selected on one page - when a user selects an item, a numeric value will be passed to a...
4
2139
by: Daz | last post by:
Hi everyone. I'm just wondering if it's considered bad practice to have a class read from and write to the $_SESSION super global. I was just learning a little about object serialization, and I've come to the conclusion that storing potentially large serialized objects in a database is perhaps a bad idea. The data could also be stored in a file, but in that case, I may as well use $_SESSION. If I'm going to go down that road, why not store...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.