singleton DB vs presistent DB

Outline by Php.net, you can create a presistent database connection, but i am wondering why would I use this method when I could create a singleton class that instantiates the db connection and exposes it by some function? ...
more »

2017-06-17 15:06 (1) Answers

Mocking tightly coupled objects in PHPUnit

For practice i'm creating my own database wrapper and query builder. When creating a DatabaseConnection object, a new PDO object is created in this object. I have a Database class which depends on the DatabaseConnection object. This class builds the...
more »

2017-06-17 15:06 (1) Answers

PHP PDO MSSQL stored procedures

I have limited access to MSSQL database, I have CentOS server with PHP 5.6 and PDO library. I need need to run stored procedures that writes result to temporary table and after that make SELECT from that table to fetch required data. IN FACT there a...
more »

2017-06-17 13:06 (0) Answers

Casting Issue in PHP PDO::FETCH_CLASS

I'm tried to fetch the data from the State Table using PDO::FETCH_CLASS, but it returns the int field as string MySQL Table Schema: CREATE TABLE IF NOT EXISTS `INState` ( `StateId` bigint(20) NOT NULL, `Name` varchar(255) NOT NULL ) My PHP Co...
more »

2017-06-17 05:06 (2) Answers

PDO registry error

i trying to make registration in website by php pdo. First time when i make account it's ok, but when i logout and make another account i getting error about duplicate email. In logout function i got sessios destroy and clear session data <?php ...
more »

2017-06-16 20:06 (0) Answers

arithmetic operation with table column PDO

I have a simple table with columns of price ,qty. cookeid and part_number. I have managed somehow to convert my old mysql code to PDO but I need help to complete the 2nd stage. To get the total price of sales for a customer, I need to choose every ...
more »

2017-06-16 17:06 (1) Answers

PDO Bind params duplicate when looping

If I run the following code: $query = "select * from city where region = :region and country = :country"; $stmt = db->prepare($query); $region = '06'; $country = 'ad'; $params = array(":region" => $region, ":country" =>...
more »

2017-06-16 16:06 (1) Answers

How to query an LongText Access field with ADOdb?

I'm trying to get data from a longtext field (MS Access Database) with ADOdb in PHP. The problem is that the longtext field value is shifted, if the length of this one is higher than 250 characters. The table structure is very simple. The table tb...
more »

2017-06-16 16:06 (0) Answers

mysql MATCH in Boolean mode not working

i have a query that should match in boolean mode that is not working for multiple words and i don't know why. If i search one word is working, when i search multiple words it does't return nothing. q=$_GET['atr']; $keys = explode(" ",$q); $...
more »

2017-06-16 11:06 (0) Answers

PDO Backup MySQL Issue

I have a code that helps me to generate and upload a backup for my MySQL database. I found this code in a non-mine project and to be honest I do not really undertand this too much, but I succeeded to implement this in my project. The problem is whe...
more »

2017-06-16 01:06 (0) Answers

Updating table with username php

I am currently working on a job claiming system and currently struggling with users being able to claim a piece of available work in my jobs table. When replacing parts of the update query called by the update button it seems to be the order_id whic...
more »

2017-06-16 01:06 (1) Answers

php error when using get request

I am trying to select and insert into a database with PDO. When I pass my parameters in the url it works perfectly. But when there is nothing in the url, i get 2 errors. Notice: Undefined index: username in C:\wamp64\www\MT\magiclogin.php on line 19...
more »

2017-06-15 22:06 (2) Answers

Set time zone issue

I want to set the time zone of my website to Europe/Brussels. I've made a small php file: <?php $DT = new DateTime($timestamp,new DateTimeZone('UTC')); $DT->setTimezone(new DateTimeZone('Europe/Brussels')); $date = $DT->format('Y-m-d H:i:s'...
more »

2017-06-15 20:06 (1) Answers

Issue with ODBC PDO and Ajax

I'm working on a project for work, and I've run into some issues. I'm creating dynamic elements based on PDO queries and ajax, and I've searched and searched to resolve my specific issue. Basically, I have two select boxes that are dynamically added ...
more »

2017-06-15 18:06 (1) Answers

Pdo BindValue with char '&'

I have a problem with my pdo request. My request works (I tried it directly with phpMyAdmin), but when $name contains char "&", it seems that bindValue doesn't work. public static function get_by_name($name, $project_id) { $statement = Eleme...
more »

2017-06-15 17:06 (0) Answers

MySQL user connexion

I am rtying to run a simple SELECT query but I get the following error : Access denied for user ''@'localhost' (using password: NO) As you can see, it seems like I'm not connected to mySQL with my username and password, but I do have a PDO object...
more »

2017-06-15 14:06 (0) Answers

Preparing and executing two queries

If i have 2 queries like this $query1 = "SELECT title, content, image FROM table1 WHERE id = :id"; $query2 = "SELECT title, content FROM table2 WHERE id = :id"; Can i prepare two of them at once like something like this $stmt = $conn->prepare(...
more »

2017-06-15 13:06 (1) Answers