tommyknocker / pdo-database-class Goto Github PK
View Code? Open in Web Editor NEWPHP PDO Wrapper which utilizes PDO and prepared statements
License: GNU Lesser General Public License v3.0
PHP PDO Wrapper which utilizes PDO and prepared statements
License: GNU Lesser General Public License v3.0
PHP 7.4 deprecated notice when inserting values using an array as the data source
The code:
$this->model->db->insert(
'roles',
[
'role'=>'editor',
'description'=>'Blog editor. Has access to blogs and blog posts.'
]
);
The error
PHP Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in vendor/tommyknocker/pdo-database-class/PDODb.php on line 435
The delete function always returns false.
Save row count in result before doing reset and return result.
I have a very complex query I'd rather pass as a SQL query, but when replacing the placeholder for an "IN" condition nothing I try works.
Is this not supported?
This does not work
$db = new PDODb('host', 'username', 'password', 'databaseName');
It maps the parameters to the incorrect parts, the type is missing.
Which means it maps host to type
This works
$db = new PDODb('mysql', DBHost, DBUser, DBPassword, DBName);
This does
$db = new PDODb(['type' => 'mysql',
'host' => DBHost,
'username' => DBUser,
'password' => DBPassword,
'dbname'=> DBName,
'port' => 3306,
'prefix' => '',
'charset' => 'utf8']);
please guide. thanks.
Hello,
when using the raw query, the database prefix gets changed.
For example, my prefix is gda_ and when using the raw query, i get an error saying
"Base table or view not found: 1146 Table 'gda.product' doesn't exist ".
I've set the prefix doing: $db->setPrefix('gda_');
What can be the issue here?
Cheers!
When i open a link localhost/web/newpanel/auth/login the below error shown please tell me what's wrong in my code please check below error and my files.
Fatal error: Call to a member function execute() on null in F:\Ampps\www\web\newpanel\Application\Libs\PDODb.php on line 972
Directory Structure
Application
-Controllers
--Auth.php
-Core
--Modal.php
-Libs
--PDODb.php
-Modals
--AuthModal.php
My Application use SplAutoload function for autoload classes
/********** Application/Controllers/Auth.php file start *******/
<?php
namespace Application\Controllers;
use \Application\Models\AuthModel;
class Auth extends MainController
{
function __construct($root_params="")
{
parent::__construct();
$this->authModel = new AuthModel();
$this->root_params = $root_params;
}
public function login()
{
$data = $this->authModel->selectAll();
var_dump($data);
exit;
}
}
/********** Application/Controllers/Auth.php file end *******/
/********** Application/Modals/AuthModal.php file start *******/
<?php
namespace Application\Models;
use \Application\Core\Model as MainModel;
class AuthModel extends MainModel
{
public function __construct(){
$this->table = "users";
}
}
/********** Application/Controllers/Auth.php file end *******/
/********** Application/Core/Modal.php file start *******/
<?php
namespace Application\Core;
use \Application\Libs\PDODb;
class Model
{
private static function getDB()
{
$db = new PDODb('mysql','localhost', 'root', 'mysql', 'newpanel');
return $db;
}
public function selectAll()
{
$db = static::getDb();
$result = $db->get("activitylog");
return $result;
}
}
/********** Application/Core/Modal.php file end *******/
The correct initialization
$db = new PDODb(['type' => 'mysql', 'host' => 'host', 'username' => 'username', 'password' => 'password', 'dbname'=> 'databaseName', 'port' => 3306, 'prefix' => 'my_', 'charset' => 'utf8' ]);
The error is for "dbname", in the README, it's 'db' =>
I lost 1 hour to find the problem ;)
Am using this library for my projects I want to know if the support is still active.
How can I get the last ID using a transaction?
$db->startTransaction(); ... if (!$db->insert('myTable', $insertData)) { //Error while saving, cancel new record $db->rollback(); } else { //OK $db->commit(); }
If I do:
$id = $db->insert('myTable', $insertData)
I get duplicate inserts
I have to update a project to php 7.2 and the intialization of PDODb didn't work anymore.
Up to Version 7.0 everything works fine.
Do you have an update or workaround for this ?
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.