473,409 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Is PDO incompatible with caching mechanismes like APC?

Hi

APC doesn't like it when I store the output of a SELECT:

===
include("apc.php");

$dbh = new PDO("sqlite:./test.sqlite");

$sql = "CREATE TABLE IF NOT EXISTS mytable (name TEXT)";
$dbh->exec($sql);

$sql = "INSERT INTO mytable VALUES (?)";
$insert = $dbh->prepare($sql);
$insert->execute(array("dead"));

$sql = "INSERT INTO mytable VALUES (?)";
$insert = $dbh->prepare($sql);
$insert->execute(array("beef"));

$sql = "SELECT * FROM mytable";
store("rows",$dbh->query($sql));

$rows = fetch("rows");
foreach($rows as $row) {
print $row['name'] . "<p>";
}

$dbh = null;
===
PHP Fatal error: Uncaught exception 'PDOException' with message 'You
cannot serialize or unserialize PDOStatement instances' in
/usr/local/www/apache22/data/apc.php:9\nStack trace:\n#0 [internal
function]: PDOStatement->__sleep()\n#1
/usr/local/www/apache22/data/apc.php(9): apc_store('rows',
Object(PDOStatement), 0)\n#2
/usr/local/www/apache22/data/test.php(21): store('rows',
Object(PDOStatement))\n#3 {main}\n thrown in
/usr/local/www/apache22/data/apc.php on line 9
===

Does it mean that PDO won't work with APC, and I should look at
another caching tool?

Thank you.
Mar 30 '08 #1
3 2440
On Sat, 29 Mar 2008 20:54:08 -0700, Jeremy <je****@pinacol.comwrote:
>It seems like what you want to do is store an array of the rows, which
is perfectly possible. Just use $dbh->query(...)->fetchAll() or
something similar.
Thanks for the tip. This code works:

$sql = "SELECT * FROM mytable";
$sth = $dbh->prepare($sql);
$sth->execute();
store("rows",$sth->fetchAll());

$rows = fetch("rows");
foreach($rows as $row) {
print $row['name'] . "<p>";
}
Mar 30 '08 #2
On Sun, 30 Mar 2008 13:26:45 +0200, Gilles Ganault <no****@nospam.com>
wrote:
>Thanks for the tip. This code works:
It works, but according to "ab", it's much slower to use APC than
hitting the SQLite file directly :-/

========
# ab -kc 10 -t 30 http://localhost/test_apc.php

Percentage of the requests served within a certain time (ms)
50% 105
66% 1054
75% 2066
80% 3089
90% 4347
95% 8136
98% 10140
99% 12148
100% 13115 (longest request)
========
# ab -kc 10 -t 30 http://192.168.0.2/test_direct.php

Percentage of the requests served within a certain time (ms)
50% 29
66% 30
75% 31
80% 32
90% 2038
95% 6072
98% 14049
99% 17056
100% 17199 (longest request)
========

Does APC start making sense with a lot more users, or is SQLite just
much faster than MySQL?
Mar 30 '08 #3
Gilles Ganault wrote:
On Sun, 30 Mar 2008 13:26:45 +0200, Gilles Ganault <no****@nospam.com>
wrote:
>Thanks for the tip. This code works:

It works, but according to "ab", it's much slower to use APC than
hitting the SQLite file directly :-/

========
# ab -kc 10 -t 30 http://localhost/test_apc.php

Percentage of the requests served within a certain time (ms)
50% 105
66% 1054
75% 2066
80% 3089
90% 4347
95% 8136
98% 10140
99% 12148
100% 13115 (longest request)
========
# ab -kc 10 -t 30 http://192.168.0.2/test_direct.php

Percentage of the requests served within a certain time (ms)
50% 29
66% 30
75% 31
80% 32
90% 2038
95% 6072
98% 14049
99% 17056
100% 17199 (longest request)
========

Does APC start making sense with a lot more users, or is SQLite just
much faster than MySQL?
This is off topic in this newsgroup.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Mar 30 '08 #4

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

Similar topics

0
by: Neil Sargent | last post by:
This is a general posting of how I fixed a problem created by using the Access 97 ODE Setup Wizard on a Windows XP machine. I hope it helps anyone who comes across the problem saves them the 3 days...
15
by: olle | last post by:
Hi folks. I learning asp.net and compare it with traditional asp and Access-developing. The issue is this one: 1/I have this Ms Acceess adp-project application that works fine on my Ms Sql...
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
0
by: Brian Takita | last post by:
Hello, I'm getting the following error at the end of this message when trying to run the ReportManager and the ReportServer: Assembly system.data.dll security permission grant set is...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
2
by: George1776 | last post by:
All, I've recently upgraded our production ASP.NET/C# application from framework 1.1 to 2.0. Since then I've been plagued by out-of-memory errors and problems with the cache object (which may...
0
by: jason | last post by:
hi experts, support.microsoft.com/kb/917072 and http://msdn.microsoft.com/msdnmag/issues/06/07/WebAppFollies/ As pointed out in these articles, users might get session variables belong to...
4
by: Hermann | last post by:
My site is a bit slow showing the main page so I thought caching query result in PHP will improve performace. Then I read MySQL documentation and saw that MySQL does have a caching feature. So......
0
by: srikar | last post by:
Hi all, I am having a problem, when I am compiling the code in 32 bit option on a 64 bit machine using the macro CPPFLAGS= -m32 I am getting the following warnings from the linker . ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.