Comments (7)
using
max_connections=1000
from pdo_class_wrapper.
Hi @MokraCota,
First of all, I just wanted to say a big thank you for taking so much interest in this class wrapper and to put the efforts in the right direction.
Well, that's true because the wrapper isn't updated for a long time, you can see it passes the decade almost and haven't bit get updated yet. But now if people start taking interest in it I will certainty update the class wrapper in the most advance and in very optimized way.
to answer your question regarding the Persistent connection Yes! The good news is here and you can pass the PDO native attributes which come inbuilt with PDO to get the benefits of the persistent connections.
// use persistent connection
public function __construct( $dsn = array() ) {
.....
parent::__construct( "mysql:host=$host; dbname=$dbname", $username, $password, array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
**PDO::ATTR_PERSISTENT => true**
) );
.....
I have tested the Persistent connection without a single glitch (max connection is 151 MariaDB) -
for ($i = 0; $i<=1000; $i++) {
$db = new PdoWrapper($dbConfig);
$rs = $db->select('s3upload')->results();
echo str_repeat("\t", 2) . 'CON NO: ' . $i;
echo '<pre>', print_r($rs, 1), '</pre>';
}
Much appreciate your unconditional help and support and I wish good health to you.
--
Cheers!!
from pdo_class_wrapper.
I am using this wrapper like this
in my main php script I initialize
$db = new PdoWrapper($dbConfig);
then I have a few dozen
$db->pdoQuery, $db->select, $db->update, etc...
then I include this main php script into my worker script php
and there I again use $db as a global variable in my functions
require_once "include/main.php";
function worker($arr)
{
global $db;
foreach ($arr as $item) {
$db->pdoQuery("UPDATE ...;");
}
}
am I using this wrapper wrong? should I initiate it in each script?
from pdo_class_wrapper.
Just took a look at my class, it seems I have an old version because
PDO::ATTR_PERSISTENT => true
is missing in mine. I'll update the script now and test again.
from pdo_class_wrapper.
I can insert 10K+ rows in a loop without any issue. Using global vars isn't opens the new connection it's class initializing which invoke the class to create a new instance with new connections in absence of a persistence connection.
from pdo_class_wrapper.
How could I find out which script is causing these issues? I'm not an experienced PHP programmer.
I have many scripts that have traffic, but I can't figure out which one is causing issues.
from pdo_class_wrapper.
Issue resolved by increasing mysql max connections value
max_connections=2000
you can close this ticket
from pdo_class_wrapper.
Related Issues (17)
- wild cards? HOT 1
- Please make a PHP8 code review HOT 3
- [Feature request] Add time elapsed in showQuery
- [Question] Update incremental value HOT 3
- [Feature request] Add more description to debug problems
- [Bug] date format is wrong
- [Feature request] Add support for PDO::PARAM_LOB
- Connect through unix_socket HOT 1
- PHP8 Compatibility
- Insert issue HOT 1
- Insert issue HOT 3
- how can you compare array against string function HOT 3
- Update query is not executing HOT 2
- SQL IN operator HOT 1
- how to write a delete query HOT 5
- Do you have the latest version for PHP7 ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdo_class_wrapper.