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
2
votes
1answer
67 views

Insert data on Data Base using PDO Prepared Statement

...
3
votes
2answers
1k views

Login System using PHP and PDO Prepared Statement

vir.php ...
2
votes
2answers
91 views
2
votes
1answer
58 views

Showing all records on a webpage

I have a connection with my database to show all my records on a webpage, and I'm not sure if this code is safe: ...
-1
votes
1answer
823 views

putting sql-query response directly to foreach-loop?

Is there any reason to not do this? Putting the query directly inside a foreach-statment when the only time the result is going to be used is within that location.. ...
1
vote
1answer
3k views

PDO Dynamic query builder

I'm trying to improve my php oop programming skills. As an exercise I wrote this class that will generate and execute dynamic sql queries. I've also writed a class to call various sanitization filters ...
6
votes
1answer
237 views

Password Hashing and SQL Queries

I am new to web development and am working on a portfolio piece, so I would like to make sure I'm not creating obvious vulnerabilities. I am wondering whether there are any clear flaws in the ...
0
votes
1answer
298 views

PDO insert data through transaction method

I have an import books function to insert more than 5000 rows at once, I did some research and did this one but some other places I saw a different kind of methods to insert without looping and ...
0
votes
1answer
81 views

insert multiple tag

I have 3 tables such as books, tags, book_tags. my objective is to insert books info along with tags (tags can be multiple or single). I have two methods one is insert books info 1st and then add tags ...
3
votes
2answers
387 views

Users management php class

After a little bit of troubleshoots, I've finished this simple users registration and login class. It uses PDO to connect to a mysql database, I've tried also to ...
1
vote
0answers
476 views

PHP PDO user class

I'm working to implement an users management class inside an already existing project, so I wrote this simple code that will be called from a controller who is responsable to hash the password and ...
1
vote
1answer
57 views

store and warehouse management class

I've already posted this PHP class few days ago when I started writing it. Now that all the methods and all the controller logics are ready, I will be ask here for some suggestions about how to ...
3
votes
2answers
107 views

warehouse management class code

I'm writing a simple class to manage a warehouse, so it's supposed that it will use a database connection. All works fine for now, and I'm actually working to finish the UI. Since I think to be a ...
2
votes
1answer
51 views

Use parameter to filter results in a database without directly allowing users to access database

So background context: I wrote this script for a personal project that holds a large amount of items, I already display and am able to filter the results based on its country/location. I am a student ...
6
votes
1answer
3k views

Role Based Access Control (RBAC) System

I have been working on creating my own implementation of an RBAC system for the purpose of: learning to use an OOP approach instead of procedural switch from using mysqli to PDO and to learn how to ...
3
votes
3answers
302 views

PHP Signup & Login

I want everything to be well and secure with my authentication code. I've done many signup and login systems before but just for testing purposes, and didn't take into consideration all the security ...
1
vote
0answers
152 views

Very simple RESTful API dispatching in PHP

This code is meant to be a very simple RESTful API. The simple router takes the URI request and maps it to a function with a matching name. E.g. www.domain.com/bill maps to function bill(). Then bill ...
1
vote
0answers
47 views

Nightly script to update database

I have a portion of a script here, and the whole script works just fine. However, I feel like it's inefficient and may work better in a class/function format. This is a script scheduled to run every ...
1
vote
1answer
53 views

Insert and update SQL entries for posts to be accessed by up to 3 other users

At first, I have this HTML I use here: body { text-align: center; } ...
5
votes
1answer
1k views

Simple URL shortener

This URL shortener is just for my own use and it runs on my local machine. I created this for fun and I doubt if I would ever use it in production. Is my script any good? shortener.php ...
3
votes
1answer
160 views

PHP RESTful API for a student repository

All of the codes are based on the PSR-2 standard. Also Dependency-Injection and Repository patterns are followed. I would love to hear some advices or comments. StudentRepository Class ...
1
vote
1answer
1k views

PHP PDO Class with multiple Select Efficiency and speed [closed]

I am very new to classes, and not sure how efficient this class is, would appreciate improvement feedback and info on efficiency including speed. The class includes a construct that creates a ...
0
votes
1answer
137 views

Making CRUD abstracted class in PHP

I did a working CRUD abstracted class, and I am not sure that this is a good way for it, so I would like to hear your opinion. ...
2
votes
1answer
147 views

Object-oriented PDO wrapper

So, I've recently started learning OOP in PHP and learned $this keyword. I know it's a reference to the current object. So I wrote a class and couple of functions ...
1
vote
2answers
339 views

PHP PDO statements

I wrote a piece of code. and to be honest it seems a bit messy so I would like some opinions on it, and if I can make it cleaner. Or if there are better ways to do it: ...
-1
votes
1answer
1k views

Mysql flexible insert record with bind_param or bind_value

I want to insert rows in a database table with the precaution of SQL-injection. I'm using below flexible MySQL insert function, which enters a record in a given table. Is this the best approach or is ...
3
votes
1answer
154 views

Finding sessions associated with an IP address using PDO

Originally Posted on Stack Overflow First of all I want to say that I'm new to PDO. I did tried it once but since I found the oop solution complicated and even impossible (...
5
votes
3answers
957 views

Ajax Voting System

Everything works, but my strong suit definitely isn't JavaScript or jQuery. I'm sure there is some way that this can be accomplished that doesn't look so hacky. HTML: ...
1
vote
2answers
1k views

Custom PDO wrapper class

I somewhat recently asked a question on here for advice on a PDO function that I had written. I got some good advice from a user, and went with it. I had used that function for about 3 months which is ...
1
vote
2answers
130 views

Session Control

I am implementing my first app using MVC. I would like to know if the approach I thought for the session system is a good and scalable one. Well, basically a session is stored in my MySQL database ...
3
votes
1answer
537 views

querySingle function for PDO

I have been refactoring a lot of my old code lately, and with that I have been switching from sqlite3 to mysql using PDO - sqlite3 has something called "querysingle" that allows you to return single ...
0
votes
3answers
3k views

PDO prepared statement to insert data into MySQL

I am changing all mysqli queries to use PDO now and just want to make sure I'm doing it right. Here is an old one: ...
2
votes
1answer
827 views

“Live” searching on a website using AJAX and PHP (MySQL/MariaDB database)

I have written a "live" search feature for my website. Whenever a keyUp event is triggered in the search field, the JavaScript performs an AJAX request to a backend ...
0
votes
2answers
140 views

PDO anonymous function inside a Factory

In this question here on S.O, the accepted answer suggests to use both anonymous function and factory pattern for dealing with PDO connection. I believe the anonymous function is used in case a ...
5
votes
2answers
827 views

Inserting users using PDO prepared statements

I made a small script to update fields in a database. I'm using PDO to connect to MySQL. All the business logic of PHP is in the top half of the file, and the form is at the bottom. Here is the full ...
2
votes
1answer
96 views

User registration function too slow

I just wrote a PHP code to register users. It's called through AJAX and it looks like it's too slow because it often sent me a .status = 0 that it means it took too much time to proceed. If i ...
1
vote
2answers
120 views

Using PDO to list and remove updates

I started using PDO 2 days ago, but I want to know if the way I'm coding and the way I'm using it is the correct way of doing things with PDO. Please let me know if you guys notice any security flaws ...
5
votes
2answers
9k views

PHP MySQL PDO Database Class

Please let me know if any improvements could be made to my PHP PDO MySQL Class. ...
5
votes
3answers
3k views

A demonstrational example of a Data mapper ORM

I want to create an educational example of a Data mapper type ORM. You know, it is always interesting to know how the stuff works, but when you take a fully functional software package, it's just ...
1
vote
1answer
117 views

Getting a connection to the database and executing statements

I've got two classes for getting a connection to the database and executing things, Class 'A' was made by me and Class 'B' was made by a colleague, we were wondering which one is better for use (...
2
votes
1answer
202 views

Registering users bank account and logging in securely

I wrote a php script to register a user's bank account and I've tried to make the login as secure as possible, but I wonder if there are any flaws and is it's free from xss attacks and sql injection ...
1
vote
1answer
769 views

Data Access Layer (object oriented)

I am using a global class (like a global model) that acts like a sql abstraction layer for my application. I am using it without problems now, but since the application I am creating is getting bigger,...
3
votes
2answers
1k views

PDO Insert Method

I'm currently creating a class that will have a bunch of my most common database functions. This is the first method I've made, I would appreciate any feedback, thanks! ...
1
vote
2answers
95 views

One object to handle all my database manipulation needs

I have created an object to handle all my database manipulation needs. Here is my object constructor and one of its functions: ...
-1
votes
2answers
217 views

Wrapper Connection PDO PHP [closed]

This is my wrapper, how can i improve this? (With a Singleton too) ...
3
votes
3answers
2k views

Login and registration pages for a PHP and PDO e-commerce project

We are doing an e-commerce project in a PHP-MySQL combination. Here is the code with PDO we wrote for login and register. I've heard that writing less code is better, so how we can reduce the lines of ...
4
votes
2answers
20k views

Simple PDO database class in PHP

I'm writing a simple database class so I could use it in my future projects. It is based on some Codeigniter database methods, but my implementation, so if you could review this, that would be cool. ...
1
vote
2answers
4k views

PHP PDO Wrapper

Here's a PHP PDO wrapper class that I wrote, along with example usage. This class features 2 primary methods for interacting with a database: Query(), which returns ...
3
votes
4answers
7k views

User registration and authentication in PHP and PDO

Please criticize as thoroughly as possible, even the smallest thing will be very useful for me. I'm trying to create a safe and easy system to change for future projects. I am aware that it should ...
1
vote
1answer
192 views

Connecting to a database and running CRUD operations

I have a database class that connects to a database and runs CRUD operations. I need a critique of how well this class adheres to SOLID principles. A class to run all database operations seems like '...

1
2
3 4 5
7