3
votes
2answers
490 views

Protecting a database from bad data

I'm just getting into SQL injection and data sanitization and seeking some advice on my script to get started. I have made this simple program which allows the user to enter their name into a form and ...
0
votes
1answer
72 views

Did you like my product?

I have the following MySQL query which selects product details and whether the viewing user likes them. I feel like it could be more efficient and that there is a more practical approach than using a ...
2
votes
1answer
44 views

DB security and efficiency in WordPress plugins

I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying ...
4
votes
1answer
91 views

My simple PDO wrapper class

I made a simple database class and I wanted to know if there are any improvements I could work on as far as readability, efficiency, methods and making it modular goes. Any other suggestions are also ...
1
vote
2answers
54 views

Where to protect DB data against XSS injections?

To protect my web site against XSS injection, I am using OWASP Encoding Project. Is it a good idea to protect all data retrieved in my DB to avoid XSS by going throuh all the data just returned by ...
1
vote
0answers
66 views

Getting a list of manufacturers from a database

I'm new to Zend Framework. Can you help me optimize this Model function, which gets a list of Manufactures with some conditions from a database? ...
0
votes
1answer
121 views

Database “design” using Symfony2 and Doctrine2

I'm working on an application, which tracks expenses. I have users, and each user can create his categories for the expenses (like Food, Bills, Transport, Drinks, Clothes) and then create expenses - ...
2
votes
1answer
68 views

Security of authentication check for a blog

I am currently making a very big blogging system for my Website where I want really neat code! So, I was wondering: is this method safe/does it have any problems with security? Yes, I'll be encrypting ...
4
votes
2answers
213 views

Extract a joined result set into a parent-child hierarchy

I'm writing a quiz application in PHP and am querying the DB for questions and their associated answers. I then wrangle the result set into a usable array for my front end. However, it always seems ...
3
votes
1answer
132 views

Flat-file DB with CRUD

I just finished writing a flat-file DB class for PHP which supports selecting, updating, inserting and deleting. I was wondering if there are any ways to make it faster or if I'm doing anything the ...
3
votes
1answer
147 views

How can I improve my PHP model for my HTML5/JS mobile app?

I am posting the a section of the model of my application. Any/all feedback would be very helpful as I am trying to build my PHP skills, but I will ask a couple specific questions that might help ...
4
votes
1answer
185 views

In-memory data cache architecture for data transfer

I am writing a cron job to manipulate and transfer remote data. I need to cache data from a table, process it, merge with previous table, iterate the process, and eventually send the result data to ...
1
vote
1answer
112 views

Need your opinions on my database normalization attempt [closed]

I'm working on a project with CakePHP where it will allow users to log their drug use. Be it alcohol, caffeine, or whatever else. When people add a log, they select the substance from a drop down, ...
1
vote
1answer
95 views

Updating visiting dates of each visitor

I am still a PHP beginner. Please review/improve my PHP code and reveal errors, typos and warnings. ...
1
vote
1answer
76 views

Login and User Information Requests

I am trying to improvise a piece of code. The best is to get reviews from experts, so here I am. Can you have a look? What do you think of it? Any suggestions? This code basically connects to a ...
1
vote
0answers
87 views

In-memory data cache architecture

I am designing basic in-memory cache storage with thin CRUD (actually CRD) interface. The design is inspired by the Backend solutions such as Parse and StackMob. Main requirements: Cache consists ...
5
votes
1answer
614 views

Generic method for database calls

Background Breaking from MVC, I've implemented the following architecture: POST/GET ➤ PHP ➤ Database Calls ➤ XML ➤ XSLT ➤ HTML All database interactions are ...
2
votes
1answer
614 views

Builder pattern for Codeigniter ActiveRecord queries

I am using Codeigniter and it's ActiveRecord. I had this idea for a base class that provided a generic getter/setter for doing simple queries on a database. I have a lot of database objects that ...
1
vote
1answer
813 views
14
votes
1answer
14k views

Very simple PHP PDO class

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job ...
0
votes
1answer
195 views

guide me to make my code perfect

I had made some of pages and they work but I'm not sure if I coded it in best way so I want your suggestions and ideas to make my code better. connection.php ...
3
votes
2answers
127 views

Querying a database with PHP

I'm new to PHP programming. I would love some feedback on this simple code I wrote which queries a database based on some arguments supplied by a user and returns an HTML table displaying the data. ...
0
votes
1answer
478 views

displaying data from from many-to-many table

ok, I'm new with MySQL, and this is a simple exercise for practice, so please bare with me. My goal is to display all posts with their categories underneath them. The code below accomplishes this, ...
11
votes
3answers
2k views

PHP PDO Database Abstraction Layer

I'd like to get some feedback on a PHP Database Abstraction Layer I've created. It's a little long, but there really wasn't a way to just post part of it. Here is the base ...
1
vote
2answers
290 views

PHP Class Inheritance / Object Instantiation / Object / Property Scope w/ Child / Parent Classes & Dependency Container Class

In PHP, I have a parent/child class and am using dependency container to load them. I am trying to use the same database connection on all of them without duplicating the object. CLARIFICATION: MY ...
-1
votes
1answer
207 views

Connects to database but cannot get table [closed]

I use this php code to connect to my databse and retrieve the table food. I am able to connect to the database but no retrieve the table. I get this as a result: ...
5
votes
1answer
754 views

PHP Login Authentication with BCrypt

So I have a php authentication script and everything works fine. But I'm very unsure about the way I programmed it (i hardcoded some stuff) and I was hoping stack could look through this and point out ...
4
votes
1answer
256 views

Please review my PDO Database wrapper

The subject is this small project - PHP/MySQL Database wrapper The three main goals of this projects are: Easy way to map database columns to object properties Simple solution to insert or update ...
2
votes
1answer
250 views

Is the following database class safe?

I was looking for a php class to handle all database operations (MySQL) and came across the following class. Someone please help me telling if this uses Prepared Statements correctly to make my web ...
2
votes
1answer
121 views

Is this an efficient way of accessing the database

**EDIT I asked this question yesteday when I was unregistered, and now I can't seem to comment on the question or mark the answer as correct but I would like to say thank you for taking the time to ...
2
votes
1answer
266 views

Newsletter SQL query optimization

I want to build a small newsletter like tool which sends mails in pre-defined timespans. First after registration, second 14 days later, third 7 days later etc. I came across for two database designs ...
3
votes
1answer
373 views

SQL injection check

Is the code below safe from SQL injection? ...
20
votes
5answers
4k views

Database connection in constructor and destructor

I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This ...
2
votes
1answer
470 views

PHP Database class

Below is the code for a Database class that wraps around a small set of the features that the PHP mysqli extension provides. I'm looking for ways to improve its efficiency. Which parts of the code ...
1
vote
1answer
426 views

General code review - PHP/MySQL/MSSQL accessor functions

I've been away from PHP for at least 5 years and I'm just starting to look into it again. I have a set of functions I created and used for database access and I'm wondering if they are still good to ...
1
vote
1answer
517 views

PHP Sign Up Form - Safe and Secure?

I just wanted to see how secure this form is, and if there are any potential problems. I tried to add mysqli_real_escape_string to the Prepared statement but it gave me an error. Also if I enter a ...
2
votes
1answer
324 views

MySQLi_STMT wrapper, allows placeholders

I've made a simple wrapper for MySQLi_STMT, allowing the usage of placeholders and spares you the need to manually bind variables. The full code is at the bottom of ...
3
votes
1answer
493 views

Question about User php class. Should I connect to DB in this class?

I have small Class which handles user's information. (name, surname, login, hash of password). Also this class can activate, register and login the user. This means I should connect to DB. Is it ...
5
votes
1answer
437 views

Generalized PHP function for editing data in a table

I've got some legacy code which I need to maintain and its got this function which works perfectly fine, but I'm trying to understand if it is working using acceptable coding practices or not... I am ...