Skip to main content

Questions tagged [pdo]

PDO is a PHP extension that serves as a data access abstraction layer for accessing databases.

Filter by
Sorted by
Tagged with
7 votes
3 answers
1k views

A simple PHP login form with PDO

I wrote a simple PHP login form for a website. It has an initialization script, as well as a form to allow a user to login, plus a link to log the user out after logging in. ...
whiteman808's user avatar
1 vote
1 answer
116 views

PHP Validation script

The code below is modified slightly from the code in this previous post. I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved ...
Bebo's user avatar
  • 39
0 votes
1 answer
218 views

SQL & PHP login method

My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and ...
Bebo's user avatar
  • 39
2 votes
2 answers
230 views

Best Practices for PHP PDO Pagination with Search Functionality

I'm working on implementing a pagination system with search functionality using PHP and PDO. The code I've written seems to work, but I want to ensure that I'm following best practices and avoiding ...
user275476's user avatar
1 vote
0 answers
55 views

PHP PDO prepared statement with IN [closed]

Here's my code: ...
neubert's user avatar
  • 111
0 votes
1 answer
260 views

Can I use PDO transaction in this way? [closed]

So I want to use PDO transaction in PHP OOP where in the class are multiple insert/update queries. If I create a new methods in Class like beginTransaction(), commit(), rollback() and I use them ...
kviktor1230's user avatar
1 vote
1 answer
379 views

Wrap INSERT statements to PDO transaction (PHP OOP)

so Im trying to wrap SQL INSERT statements to PDO transaction in PHP OOP. I don't know if I'm doing it right and this is the best/easiest way to do it. So what is important for me is: There can be ...
kviktor1230's user avatar
1 vote
1 answer
275 views

Is this PDO query okay to use in PHP OOP?

Do you think this code is good if I want to do a simple SQL query? Is it safe to use? Or am I doing something wrong? ...
kviktor1230's user avatar
5 votes
3 answers
254 views

DB Class extending PDO w/ other useful functions

I have this DB class that extends PDO, that also has useful functions for certain tasks; I was wondering how well it's coded, and if so, what I could maybe improve on. I tried commenting in ...
Crimin4L's user avatar
  • 153
3 votes
1 answer
212 views

Proper PDO connection function

I am reviewing the database class for a live website. I am not sure if the current connect function is the best way to create a pdo object as it appears to create a new connection every time it is ...
jdf's user avatar
  • 31
1 vote
1 answer
73 views

Updating multiple database tables when products are shipped back by customer

So, in this example I have to make these changes in my tables: Select Product Data => SKU, QTY Insert into shipping_back table Update in shipping_back to current date Update in customers to ...
kviktor1230's user avatar
1 vote
1 answer
86 views

batchUpdate using pdo and MSSQL

...
Sayaman's user avatar
  • 415
7 votes
2 answers
206 views

Connect to MYSQL database in PHP with prepared statements

I have recently learned about using PDO. I created a db class which could handle common actions like create, update, delete and select. Is this method a correct way to connect to the database using ...
Sanidhya's user avatar
3 votes
1 answer
124 views

Pagination helper class

The most nauseous problem with pagination is the fact that you have to write two almost identical queries. For the various reasons I am not inclined to use the SQL-only way (such as ...
Your Common Sense's user avatar
4 votes
2 answers
204 views

Using a transaction to create account records

This is my first time using commit and rollback. I just need to know if this is a proper execution of the functions for this particular situation: ...
John Beasley's user avatar
5 votes
1 answer
140 views

Storing and confirming user input

I am a beginner, and I'm trying to secure a sign-login system on my website. Is my code good/enough to prevent SQL injection? THIS IS THE SIGN FILES This is the index.php that takes user input: ...
irtexas19's user avatar
  • 173
1 vote
3 answers
109 views

What is the best way to login according to account type with server-side validation?

I have two access roles as of now for example account_type 1 and 2. What I am doing is, <...
user9437856's user avatar
1 vote
0 answers
322 views

Registration and login via PDO

don't blame me I am trying to learn, the code works but I am not sure it is well optimized. Please tell me if you see something wrong. My goal is to achieve most optimized code (and learn something in ...
xkp's user avatar
  • 11
4 votes
2 answers
448 views

API for SQL queries with PHP PDO

I'm writing a very simple CRUD application, and I'm wondering if the way I'm using static methods throughout the code makes sense. I'd very much like to simplify ...
GingerBadger's user avatar
5 votes
1 answer
488 views

function for PDO queries and return result - tested - any tips?

I write a function using PHP and MySQL, to get PDO connection, query and array of placeholders to execute query and return result. I test this function and it has good response when result for ...
sidoco's user avatar
  • 53
1 vote
2 answers
127 views

Repeated DB connection at max user connections

I am trying to create class with connect to mysql database. And if there is max number of connections I want to wait and try it again. I figured out, how it can works, but I am not sure, if its the ...
Tomáš Kretek's user avatar
3 votes
1 answer
672 views

Sanitizing user form input in php

Security threats in mind: SQL Injections!!! --- Solutions: Prepared Statements (PDO) and including $bpdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); in ...
user avatar
5 votes
2 answers
636 views

Mysql PDO Wrapper that throws Unique Constraint Exception

The main reasoning behind this PDO wrapper, is that I find myself using unique constraints quite frequently in my designs, and I have ...
bumperbox's user avatar
  • 2,096
-4 votes
2 answers
563 views

Is this a good approach to replace mysqli_num_rows? [closed]

Is this a good approach to replace mysqli_num_rows? $db is a PDO instance. .. ...
Ingus's user avatar
  • 215
8 votes
3 answers
1k views

How secure is my PHP registration script?

I coded a registration form and was wondering if anyone could give me feedback on whether I'm lacking any major security mechanisms. I've done loads of reading around the topic and feel it should be ...
sharkmountain's user avatar
3 votes
1 answer
776 views

Does PDO::quote helps me to protect me against sql injection?

I have to process raw sql user input with Laravel. I've backed them up as follows: ...
Phillipp Schwarz's user avatar
2 votes
2 answers
87 views

Unnecessary loop in database population

I was looking over some code that I wrote years ago (that is still technically working, albeit on a very quiet production server) and I came across this segment of code. ...
Stumbler's user avatar
  • 123
1 vote
2 answers
177 views

Is this code written safe from attacks?

I have small question. I don't know much about JavaScript (jQuery) or AJAX and I don't know whether I'm doing it safe from XSS Attacks, SQL injection and that stuff. I think the PHP with MySQL would ...
Tomáš Kretek's user avatar
2 votes
1 answer
322 views

What is the best way to use serverside validation in PHP PDO?

I have a form on my page. I am using jQuery validation for client-side and PHP for server-side validation. I am using PDO. I don't have any issues with client-side and server-side validation. My form ...
user9437856's user avatar
2 votes
1 answer
101 views

Does this PDO process look protected from SQL injection?

Does this process look protected from SQL injection attacks? Is there something I could possibly change to make it more protected? ...
John Beasley's user avatar
1 vote
1 answer
83 views

Reduce database touches for one to many data pull

I have the following function which works properly and returns all of the rows from a specific table, then loops through each row to add data related to it as a subarray. ...
GrumpyCrouton's user avatar
5 votes
3 answers
1k views

Dynamic insert function for PDO (for any case)

I created a dynamic insert function for PDO. It does work, but I want to be sure that it is secure and well coded. ...
Ingus's user avatar
  • 215
2 votes
1 answer
100 views

Extract users and privileges from MariaDB and MySQL

This was born out of a need to create database users on a new server to allow views to be created correctly when restoring databases. This is designed to be run from a command line NOT via a web ...
Dave's user avatar
  • 270
3 votes
1 answer
2k views

Add post to favorite in PDO and mysql

After lot of research and couple of questions in https://stackoverflow.com/ i managed to create Favorite System in PDO mysql as ...
sanoj lawrence's user avatar
2 votes
0 answers
408 views

PHP Secure Remember Me for Login using PHP Session and Cookies with referer url

I have followed a mysqli tutorial to create a login with cookies and session with remember me authentication in pdo. in tutorial class had a new db_connection, I ...
Ercan Koç's user avatar
4 votes
4 answers
2k views

Simple login script with sha256 hashing

I have been using this code for a while. I got it from a tutorial 5 years back. Now I'm wondering if it still is secure, or if it's time to find a new one? Maybe it has never been secure enough. ...
Björn C's user avatar
  • 151
3 votes
1 answer
106 views

PHP complete pagination code

I'm working on a site where you can read about different songs, listen to them, rate them etc, same with their singer. I've been thinking about how I could create a simple, yet perfectly working ...
K. P.'s user avatar
  • 243
2 votes
1 answer
265 views

PDO Is this registration secure and well coded?

i finally have been moved to PDO (from MySQLi) and i m now trying to make simple login and registration page (for training purposes). This code does work! But i want to know if it is secure? Also ...
Ingus's user avatar
  • 215
1 vote
1 answer
64 views

Categorize & sub categorize from contents of one row and more execute even more queries in results

I have a table called sales and it has below columns: 'id' 'product_type' 'soldDate' 'text' ...
LetsSeo's user avatar
  • 163
4 votes
2 answers
134 views

Query to plot a histogram of song ratings

I wrote code to plot a rating distribution, which looks like this: The most important function is the stats function: ...
K. P.'s user avatar
  • 243
2 votes
2 answers
72 views

SQL prepared statement to search songs by various text fields

As we know, using PDO and prepared statements, binding a table or column using bindParam is not possible. So for this, I've figured out to use function parameters ...
K. P.'s user avatar
  • 243
5 votes
4 answers
153 views

PDO MySQL queries for web application to reserve a vehicle

I normally use MySQLi and this is my first time trying out PDO. I am doing this because this is my first web application that is going to be used by the public, hence I want it to be secure. The code ...
tony's user avatar
  • 349
1 vote
1 answer
139 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
Nino's user avatar
  • 21
4 votes
3 answers
237 views

User management OOP php class

I found a class that i coded for an old project about a year ago and i haven't really touched php in a while. Now i need to use similar functionality again i thought it would be the perfect time to ...
Rajbir's user avatar
  • 143
1 vote
1 answer
117 views

Database connection and DataMapper

Following my previous question Database interface and PDO adapter, I wrote a new simple class to connect to Database and run a query returning a PDO statement. ...
fabrix's user avatar
  • 35
2 votes
1 answer
733 views

Database interface and PDO adapter

I'm writing my own framework in PHP and I want respect the SOLID principles. I made this interface: ...
fabrix's user avatar
  • 35
3 votes
2 answers
388 views

Elegant and secure way to create a dynamic query

I want to create a dynamic query to display: all the invoices if the user has moderator rank only his invoices if the user is a simple member code ...
Rocstar's user avatar
  • 131
1 vote
1 answer
101 views

Displaying a paginated list of forum topics using PHP PDO [closed]

Can someone tell me if this code is safe? Can be sql-injected or something else hacked? Code get some rows from db and show in pages with pagination... if i can improve let me know and show me how, ...
No Name's user avatar
  • 21
4 votes
1 answer
76 views

Proper use of mysqli->close();

database.config.php ...
vtcs's user avatar
  • 41
2 votes
1 answer
157 views

PDO library to handle MySQL queries

This is my library class. This does not have any issues but I want to know if I have any mistakes, or ways to improve performance: variable and call (example of ...
Minos Framework's user avatar

1
2 3 4 5
7