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
0
votes
2answers
75 views

Database in Class for Reusability

Does this code fine for database reusability? ...
-1
votes
1answer
193 views

Is the format of this PDO mysql statement correct

I have been writing simple php programs, trying to adhere to the PSR standards, for writing code. However they do not seem to have any standards for writing mysql PDO statements in. For example I ...
2
votes
1answer
44 views

Eliminate redundancy from session authentication

I have a session authentication script and it works, but I can't find a way to eliminate the redundancy where the two database queries are. One checks if the cookie has a corresponding entry, and the ...
0
votes
1answer
54 views

Function that calls the database connection and query

I made a function that contains the database connection and query. Now I'm always calling this function every time I need to query a database. Is it good or is there another way better? Database ...
1
vote
1answer
94 views

Moving To Object Orientated Programming

Please keep in mind I am new and still learning when reading the following. What I am doing I have the following code which pulls a sport, tournament and round NR, from a DB table called ...
2
votes
1answer
28k views

PHP PDO login with session

index.php,general message.php, logout.php, site ...
2
votes
2answers
104 views

Checking a user's emails using an ID

I'm trying to do this: Getting user's ID based on his email name. Using that user_id to check all his emails that have been sent for him so far. ...
1
vote
1answer
13k views

PHP login form with PDO

I create login form with session with four files: connection.php login.php plan.php logout.php Please check my code and tell about any smokestack. Database educate (create table users) ...
1
vote
0answers
600 views

Printing many-to-many relationships in an HTML/bootstrap table

I need to print the many-to-many relation ship in my tablet. However, I don't know what to do for my case: I tried tons of ideas, however, I may have done something wrong because nothing worked. Here ...
1
vote
1answer
7k views

Database connection in MVC model

I followed the tutorial Build a PHP MVC Application and have implemented a database connection. I made a seperate database connection class and I call it in the controller. It works, but now I have ...
2
votes
2answers
499 views

Setting up a database class

I am wondering the best way to setup a database class, to remove repeat code by using OOP. This way if I changed how I connect to the database (switch from PDO to sqlsrv driver) I can just change it ...
1
vote
3answers
1k views

Selecting a table with multiple ID on MySQL using PHP PDO

I have made a MySQL script to query a table with a set of id using an IN clause and after some reading I found out that there are security issues with it like prone ...
5
votes
3answers
447 views

Running a MySQL query with an admin class

This is my admin class, DB class and how I use OOP. I am looking for ways to improve my code to make better use of OOP. Please help me if you think I can improve my code in some way. db.class.php <...
2
votes
1answer
357 views

Simple PHP MVC framework

I recently wrote this PHP MVC framework. Would like your review. index.php ...
3
votes
2answers
11k views

PHP MySQL connection class

I'm trying to build a class that connects to the database. It does the job but it is not very elegant. I also have no understanding of singleton class or dependency injection. Is this safe? Can you ...
2
votes
1answer
712 views

Managing PostgreSQL transactions for concurrency

I have a situation where I need to use PostgreSQL's serializable isolation level for transactions. This is for a table shared among multiple concurrent PHP processes. If the database runs into any ...
1
vote
2answers
622 views

Lookup class to get descriptions of values

Following yesterday's advice on my Customer class, I have now created a new class which is for looking up descriptions from a MySQL database. I have a Lookup table which contains type, name, value, ...
3
votes
1answer
3k views

Simple customer SQL query using a class and function

I have been writing PHP for a number of years but in a procedural style. I have always shied away from object oriented PHP because I just didn't understand it. However now I'm back for another go. I ...
1
vote
5answers
858 views

A like/unlike system using MySQL and PDO

I have created a Like/Unlike system. The user clicks one to indicate a "like", and clicks again to "unlike" it. Currently I do that like this: ...
3
votes
1answer
1k views

PDO update method

I am in my first object-oriented project and wrote this method for updating the database. The PDO include is just for convenience, so I could work on a single file temporarily. I'm not entirely clear ...
1
vote
2answers
2k views

Select random row using PDO

What do you think of this way to generate a random number from the total rows in a table? I would like to create a page that random.php precisely generates a random ID and shows it. ...
1
vote
0answers
160 views

Simple data-fetching and conversion into JSON using two different patterns

I'm trying to fetch and convert data into JSON format. Some days ago I was using MySQLi but someone told me this is susceptible to SQL injections when I asked a question for code review. Now I'm ...
4
votes
2answers
905 views

Using PHP PDO to fetch employee details

I am finally making the move to object oriented PHP. This has been something I have been quite reluctant to do, but I now feel that it could benefit me, and bring me up-to-date with current practices. ...
3
votes
1answer
381 views

Efficient MySQL PDO class

I tried to create a secure and efficient PDO class. I would really appreciate your feedback to make it more production-ready. GitHub ...
1
vote
1answer
45 views

Bulk customer creation

Here is my script which takes 50k records from a CSV and does CRUD operation with them. Unfortunately there are a lot of issues with the performance. CSV fields are: msisdn, resellerid, product ...
2
votes
1answer
134 views

Inserting a record into a MySQL table using PDO

Already many days I'm documenting about the SQL Injection. I was wondering if the code I wrote is vulnerable in some of its parts. ...
2
votes
2answers
116 views
0
votes
1answer
98 views

Inserting a role using PDO

My question has to do with : (a) Can this be made more secure? (b) Are there best practices in relation to setting timezone? (c) What best approach should be taken defining use of utf8? ...
2
votes
1answer
1k views

PHP Login script getting bypassed allowing access to my admin pages

I have a site where a friendly hacker says they have accessed my admin area. I am not able to see how this is possible so any help would be greatly appreciated. I am using PDO prepared statements to ...
2
votes
1answer
3k views

Global site settings middleware for Slim Framework 3

I have created this middleware code for slim. I just want to know that is this right way to store site settings globally. so, I can use where ever I want. What do you think about my class structure ...
1
vote
2answers
68 views

Details of a user

Would you please recommend how I could improve this code? My PHP editor only gave a warning about the variable $id. ...
1
vote
1answer
377 views

Database query inside a method of a class and return data [closed]

I'm trying to find out what is the right approach to return DB values from a class. This is what I came up with: ...
0
votes
1answer
107 views

Proper class user.php

I'm learning to program with PHP, so I ask your help to check if my class user.php is ok. ...
2
votes
1answer
245 views

PHP page to edit a user account information and avatar

I wanted to ask your opinion about my code created for acccount.php page for editing the data of each logged-in user. I wanted to have more of an opinion on your right syntax, though maybe it could ...
4
votes
1answer
211 views

PDO connector class

I have created a DB connector class with PDO. Do I need to add, delete or edit anything in this code? ...
2
votes
2answers
1k views

PHP Dynamic QueryBuilder function - Security

This function is a working function, which builds a number of queries depending on the values of $_POST. ...
4
votes
1answer
81 views

Possibility of SQL Injection

I am requesting a review of a portion of a 600 lines of code. This portion of the code process a filter that is farther down the page. It takes in the parameters and formats them into a query. Now I ...
2
votes
1answer
210 views

Writing PHP PDO bindParameters

Is there a better way to write this? ...
3
votes
1answer
139 views

Extended PDO class for MySQL

I recently started with object oriented programming in PHP and I am wondering if my database class is on the right track. Am I doing something wrong? If so, how can I improve it? Here is the class: ...
5
votes
1answer
165 views

Tools for transferring data from an API to a database

I explain everything on my current code but this question is more general "HOW TO" work correctly with this in this case but even next time. I have 4 methods in my class, each does something but in ...
5
votes
1answer
503 views

Database Session Class

I have made the decision to move the storing of session data from the filesystem to the database. Our application is growing at pace and we are having issues with the load balancer breaking the ...
2
votes
2answers
74 views

Returning the number of records per day

I'm writing a query to get the number of sessions created each day for the past 90 days. I'm currently using a prepared statement to do this - looks something like this: ...
6
votes
2answers
153 views

A class to add and select players within a database

I have a question and want to know if my class is considered object oriented. ...
2
votes
2answers
338 views

A simple PHP login system

I'm super new to PHP and I'm trying to get a functional login system together. This is the code I have: class/user.php ...
3
votes
2answers
226 views

Classes, one responsibility principle and magic methods

I am currently building a small application that allows users to create a slideshow, each slideshow consisting of slides that are either videos or images. Although this will be relatively small at ...
3
votes
3answers
276 views

Web page to add a notice, with some validation

I'm displaying multiple queries and if statements. In the if statement, it increments ...
1
vote
1answer
2k views

PDO - configuration, database connection & and using

I'm currently reading a book and watching some tutorials about PHP with MySQL (PDO), but it is not clear where to put certain things - where to put some code, should I put the connection to the ...
1
vote
1answer
228 views

Bind variables in PHP-MySQL

I am using the below code to execute a MySQL query in PHP. ...
0
votes
1answer
612 views

PDO lastInsertId

In my shop system I'm using the PDO lastInsertId to assign the order_id to the products that belongs to it like this: ...
5
votes
1answer
3k views

PDO Insert function using PHP

This code inserts data into the database successfully. I was concerned about whether it is a considered good practise to go about inserting data into the database in this way. Is there something I am ...

1 2
3
4 5
7