Giter Site home page Giter Site logo

pdo-database-class's Issues

PHP 7.4 PHP Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in vendor/tommyknocker/pdo-database-class/PDODb.php on line 435

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

Pass array for "IN" in RawQuery

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?

Correct the read me

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']);

Raw query changes the DB prefix

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!

Fatal error: Call to a member function execute() on null

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 *******/

Errors in README - Advanced initialization

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 ;)

Active Support needed

Am using this library for my projects I want to know if the support is still active.

Get last insert ID for transaction

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

php 7.1

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.