noncent / pdo_class_wrapper Goto Github PK
View Code? Open in Web Editor NEWA Class for PDO Wrapper
A Class for PDO Wrapper
Can you please review this wonderful piece of code, if it's compatible with PHP7 and PHP8?
Hi Admin
I have a delete query not able to execute using the class.
Here is my query, please let me know how to execute
DELETE FROM students WHERE studentID IN (1,2,3,4,5)
Regards
Narasimha
Please add elapsed time information to the showQuery method.
Hi
I am using you pdo wrapper. I am having problem in updating sql query. I am not getting any error but the query is not updating
$pObjDB->update('usertable', array('username' => $newuser, 'password' => $passwordMD5, 'acctype' => 0), array('username' => $username), 'LIMIT 1')->affectedRows();
I am not able to understand what I am doing wrong, but the same query is running successfully in command prompt.
UPDATE usertable
SET username = "test12", password = "81dc9bdb52d04dc20036dbd8313ed055", acctype = 0 WHERE username = "test" LIMIT 1;
Could please help me out
Is it possible something like this, with IN operator:
SELECT * FROM Customers WHERE City IN ('Paris','London');
Thanks
Hello,
how would I use the update method for incremental values?
example:
UPDATE table SET value = value +1 WHERE id = 1;
This doesn't work as expected:
$db->update("table", array("value "=>"value + 1"), array("id"=>(int)$id));
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'value + 1' for column 'value' at row 1: update - table: 711
Issue while inserting row with insert()
I have counted it has enough matching parameter though it shows mismatch error
Executed Query -> INSERT INTO table
(user_id,title,description,address,latitude,longitude,property_id,outdoor_size,late_bookings,cancellation_policy,created_date) VALUES (2,"poodles r us","poodles r us makes u dog happy! NO kennels, just friendly people TO look AFTER your dog WHILE you re away! think OF us friends","slough, slough, slough sl3 8ay, uk",51.5006615,-0.5303367,6,"medium",1,1,"2014-08-19 22:36:23");
ERROR:"SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: 480"
Hi, I found your wrapper class helpful and so wanted to use it. but before I start using it, Is there any latest version of the wrapper class available with you ?
I also read that new version coming soon in the introduction page but looks like this repo is not updated since last few years..
let me know if I can wait few days for latest version ?
Thanks
the date format for log entry is wrong:
date('Y-m-d h:m:s')
Should be:
date('Y-m-d H:i:s')
Please consider adding PDO::PARAM_LOB support
Thanks for this great Class! But one think...
There's now way to connect an Server through unix_socket- but big Hoster like 1and1 prefer a connection through socket.
My Workaround:
try {
// use native pdo class and connect
//if connection via socket
if (isset($dsn['socket'])) {
parent::__construct("mysql:unix_socket=$socket;dbname=$dbname", $username, $password, array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
));
} else {
//Normal connection
parent::__construct("mysql:host=$host; dbname=$dbname", $username, $password, array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
));
}
}
--> If an Parameter 'socket' is given via db config, the class connect through unix_socket... quick'n'easy, yeah, but it works :-)
Im getting an error in PHP 8 General error: 2014 Cannot execute queries while other unbuffered queries are active, trying to run this query:
$db->pdoQuery("
UPDATE sites
SET users = CASE
WHEN users = 0 THEN 1
ELSE CONCAT(users, ',1')
END
WHERE id = " 3
)->results();
It works fin in PHP 7+
When you use this class in a while or for loop, you will get errors
ERROR in establish connection: SQLSTATE[08004] [1040] Too many connections
which indicates, that this class does not reuse connections, but instead opens always a new connection?
When passing a wildcard to select, it produces an error. For example:
$q = $db->select('Wells', '', array('Name LIKE '=>'%anderson%'))->results();
With PDO, execute(array(':Name'=> '%anderson%')) will return a wild card match. I went through the class quickly to find why this was happening, but didn't spot it.
Hello,
please enhance the self::error
calls, to add more details.
I had multiple pdoQuery calls, but I didn't know in which call I have an error.
So I changed the pdoQuery method to help me out:
} catch (PDOException $e) {
self::error($e->getMessage() . ': ' . __LINE__ . ". SQL: " . $sSql);
} // end try catch block
Would even help more if I knew where in my original script I had the error - filename and line. Maybe something that can be achieved with $_SERVER["SCRIPT_FILENAME"]
Issue while inserting row with insert()
See line no near 389: if(strstr(key($aWhere), ' ')){
$aWhere is array how can you compare with string function. this issue is present throughout class in all functions.
And if you add operators like '>' in array('field >'=>$val) will return an error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.