Tagged Questions
16
votes
5answers
3k 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 ...
12
votes
3answers
5k views
CodeIgniter Active Record Subqueries
I use CodeIgniter at work, and one of our model files had a lot of subqueries in it. I originally had to manually write each subquery, and wondered if I could use active records instead.
So, to make ...
9
votes
2answers
429 views
A take on DB Abstraction - PHP / MySql
It's a little bit more code but i wanted to show the full class. I highlight the points i'd like input after the source.
I've cut comments since they where not in english and translated the important ...
8
votes
3answers
2k views
Basic user registration code in PHP
My first attempt at a user registration code.
Login.php defines database log in variables (e.g. Database name, Table name, etc)
Header.php connects to the database.
I used ctype_alum for security of ...
8
votes
2answers
362 views
Object Paradigm for PHP, Practice in Design
I've created and I manage a point of sale web application built in PHP which has thus far followed no clear guidelines or methodology for development; it's operation is completely procedural. In turn, ...
7
votes
5answers
7k views
Database class using PDO
The point of this question
What about this piece of code? I'm actually using it while developing a simple application and it seems to cover all my needs. Also it uses PDO so that we don't really have ...
6
votes
2answers
429 views
Comparing data in 2 tables on different servers
So I've had a problem where I need to compare data in 2 different tables on two different servers. Now, I know MySQL supports CHECKSUM TABLES, but from my testing and understanding, it's not reliable ...
6
votes
2answers
2k views
PHP classes for database connection
I work on a web application that I inherited from a colleague long gone. To connect to the MySQL database I use the following classes:
statement.php
<?php
//class sql
//{
class Statement
...
5
votes
2answers
551 views
PHP/Doctrine bootstrap for review
Here's my bootstrap.php for my PHP/MySQL/Doctrine app. It's my first PHP app so I'm interested in learning from the experience of others how this could be improved - security-wise, performance-wise, ...
5
votes
1answer
338 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 ...
5
votes
2answers
312 views
Database method to query
I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var.
Now i'm working on a method that can be used to query in this way:
$db = new ...
5
votes
2answers
2k views
PDO wrapper class
<?php
class Database
{
private $_dbh;
private $_stmt;
private $_queryCounter = 0;
public function __construct($user, $pass, $dbname)
{
$dsn = ...
5
votes
1answer
133 views
Is there any problem in checking PHP PDO connection this manner?
Is there any problem in checking PHP PDO connection this manner?
Is this way reliable?
function pdo_mysql()
{
$mysql_string = "xxxxxxxxxxx";
$mysql_user = "xxxxxxxxxxx";
$mysql_pass = ...
5
votes
1answer
149 views
Please critique my newbie PHP code
I'm a complete PHP beginner and would like some feedback on this registration page I've created. Now, the one thing I know right off that bat that's wrong with it is that there's WAY too much ...
5
votes
1answer
351 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 ...