Questions about PHP, a widely-used general-purpose scripting language that is especially suited for Web development.

learn more… | top users | synonyms

1
vote
1answer
13 views

How to organize code which converts from one type to another

If I have a DateRange class, and I want to translate a DateRange into SQL (e.g. some_col >= '2015-3-5' AND some_col <= '2015-3-5'), where should I put the method that does the translating? ...
1
vote
0answers
47 views

MVC with Post/Redirect/Get

I have a question in mind for the MVC pattern for a long time now. When using the Post/Redirect/Get principle then it doesn't make sense to use ONE model in the sense of MVC, right? Why should I ...
0
votes
0answers
16 views

problem with “real_escape_string” [migrated]

i am having some troubles my the "real_escape_string" and i need some help login.php <?php include('Connections/local.php'); ?> <?php function GetSQLValueString($sql) { $sql = ...
0
votes
2answers
28 views

Executing scripts in parallel based on dependency tree

We have an app that is using a fairly simple stack (Linux, PHP, Oracle, Shell Scripts, etc). We have a series of scripts that need to be executed: /scr/app1/start.sh /scr/app2/start.php ...
0
votes
0answers
35 views

php website on multiple servers

talking about a given website (written in php) that is hosted on multiple servers (more than 10 web and database servers with load balancer), I was wondering about few things that i am unable to ...
0
votes
0answers
4 views

How do I remove spammy links in WP theme footer? [migrated]

I got a little obstruction. I have a free theme, which I like, but I found out that in the footer there are too many commercial links (Let me say spammy links). I want to keep the credits to the ...
-1
votes
1answer
24 views

Laravel - BLOB File Management System - Possible obstacles?

I'm working on this weird project where I need to upload huge files (500mb+) and store them in a postgresql table as a blob. Before you start telling me that storing files in the database is bad and ...
1
vote
1answer
60 views

Best way to centralise a php project (except bitbucket)

The structure is as follows: A: this is the live/production website B: this is the staging, which is a copy of live C: this is the testing environment for designers 2 developer and 2 designers. ...
-4
votes
0answers
22 views

Sync Microsoft dynamics(nav) with remote mysql

I am very new to dynamics.I want to sync dynamics data with Mysql Databse in my server.So that when ever I enter new data into Nav it should also reflect in my website(which is build with PHP and ...
-4
votes
0answers
42 views

What kind of PHP code is this? [on hold]

What kind of PHP is this? I have searched Google for hours looking for a clue to what type of php it is. Below is a sample snippet of the php code I need to find a tutorial for. I code in normal PHP ...
-3
votes
0answers
20 views

Help converting python::bitstream usage to PHP equivalent [on hold]

I need to read some data coming in from a client via a SOCKET using PHP. I found an example in python but I am not a python programmer. Here is the full python example code I am trying to covert. Note ...
0
votes
0answers
18 views

Prevent Timeout for large scripts without changing any System Settings

Current Option If I have a process that I know may take a while I have been chopping it up using ajax to do a part of the request then once the ajax is returned do the next part of the request. This ...
0
votes
1answer
50 views

Where to put utility classes in php mvc?

I'm working on my first MVC website, where can I put utility classes like Security and Date (my native date) classes, are they model too? App | |--- Model |--- Controller |--- View
1
vote
1answer
19 views

PHPUnit > Best approach to mock container objects? (e.g. $item->id)

I'm using PHPUnit test doubles to mock models, libraries etc. But when I want to return an array perhaps of container objects, how best to do so. Here is what I'm currently doing: /** * This is just ...
-2
votes
0answers
36 views

PHP only showing records by id? [on hold]

I am having trouble with this PHP code and I am not sure how to title it! I have a car showcase and I am wanting the Database to display the cars depending on their ID e.g 1 Ferrari Enzo, 2 Porsche ...
1
vote
1answer
38 views

PHP MVC Model with a method to fetch all of the model from database

I have a crazy question, consider I'm developing a blog website, There is two model named Post and Comment, now I wanna add a method to fetch all comments from database, which model should I choose to ...
0
votes
0answers
13 views

How to push data from one page to another [PHP] [migrated]

I'm using sockets.io, express and php and I was wondering if it is possible to push something of a page (that only a specific user can see at the time) to another page other can see. For example, if ...
1
vote
1answer
74 views

Need to store Multiple Images (path) into MySQL after upload [duplicate]

I am trying to build my own little eCommerce CMS, and i want the expert opinion on how to handle multiple uploaded files (images). For Example: A user adds a new item, fills the necessary form data ...
0
votes
2answers
162 views
+100

Storing and retrieving simple data within a framework

I'm determined to get a decent answer to this, because while I have my own approach (constants) I'm not convinced I'm doing it as efficiently as I could be. So I'm editing the entire question, to ...
0
votes
0answers
30 views

Preserving Pre-formatted Multi-Line Strings in Node.js Scripts

There is a lot I don't like about PHP, but one thing I love is multi-line strings: $query = <<<EOT select field1 ,field2 ,field3 from tableName where field1 = 123 EOT; ...
0
votes
1answer
72 views

Database object mapping, good practices [closed]

I think I've understood the basic idea behind object mapping but there is one gap in my knowledge base that I hope to fill now. First let me tell you what I understand out of the whole thing. I have ...
2
votes
1answer
73 views

Scheme/Design Pattern for allowing a certain outside class to set properties

I came up with a solution (in PHP) to a problem and am wondering if it is a named Design Pattern, and if it is good practice. I have a collection class and an item class. The collection class is the ...
0
votes
1answer
56 views

How to efficiently determine when changes occur in event lists

We have a system that stores event information. There is a primary list of events as well as a secondary list, these may overlap. Secondary lists are combined with the primary based on 3 main rules. ...
0
votes
2answers
57 views

PHP extended class method requires same signature including object class requirement? [duplicate]

Not sure exactly how to phrase the question succinctly for the title. I have a collection class that extends another collection class. The parent collection-class has a method addMember(someClass ...
0
votes
0answers
50 views

How to dynamically print a URL as a QR Code using PHP (Drupal Views)

I'm working a small home project, and I wish to dynamically produce a QR code on a content Node (I'm using the Drupal 7.3x CMS framework and specially the Barcode Module). I've not had much success in ...
0
votes
1answer
75 views

How to appropriately structure a script used in an AJAX call?

When I first learned AJAX, I was also teaching myself the languages of PHP, JavaScript, SQL, HTML, and CSS. I followed my coworkers existing web apps as examples of how to write my own web ...
0
votes
1answer
55 views

How to handle coding errors in my PHP AJAX code?

How do I handle coding errors in my PHP which has no GUI, only an API? I am concerned that I might never know that there are any. Note that only I will develop the client side. This is not a public ...
0
votes
0answers
22 views

Architecture: Validate polymorphic votes - Controller or Model?

I have a question because I don't want to do something wrong. I have a polymorphic relation called votes. Well, I want to save votes but I need to validate if a user already has voted. But even if, ...
0
votes
2answers
37 views

Best Way To Store Images For Mobile Synchronization

The scenario is, I have a Web Dashboard (Developed using PHP + MySQL) and have Android and iOS Apps synchronizing data from the Web Dashboard (only one way i.e. Dashboard to Mobile Apps) Now the ...
0
votes
1answer
66 views

Is this a good service locator, and is this service locator pattern(?) OK?

I'm working in Zend framework 1 and was using Zend_Registry to store objects so that I could replace them in my controllers while unit testing: $auth = Zend_Registry::get('Auth'); // set in ...
0
votes
0answers
46 views

PHP mail templates

I'm working on a webshop (used to be for just one product, expanding it to multiple products and multiple shops hooked up to one backoffice, can't use PrestaShop because of compatibility). We send 3 ...
3
votes
1answer
203 views

How to hide a honeypot ( excluding external CSS and JS )

I am adding spam protection to my personal php framework and I think honeypots are a great way to block spam. Unfortunately they weren't invented yesterday and probably most bots do fetch CSS and can ...
2
votes
1answer
166 views

An embedded C developer wishing to interface some code with a web page

Okay, so as the title says, I'm an embedded C/C++ developer. Right now, I'm working on a project that involves a client/server C application. The server side of the application is running on ...
0
votes
1answer
94 views

Protected properties vs protected getters

If I have an abstract Animal class with a $name property and constructor like this: abstract class Animal { protected $name; public function __construct($name) { $this->name = $name; ...
1
vote
1answer
84 views

mySQL / PHP design pattern - one function multiple queries

So here's the gist of it. I'm looking for a design pattern where I can have one function, say queryHandler that gets the query and the parameters from a number of different functions and returns the ...
0
votes
1answer
42 views

Like structure table with Laravel and showing the most popular content at top

I am using Laravel to creating a website, my users can post questions and other users can write their comments under the post, each comment have Up vote and Down vote, and users can voting for ...
-1
votes
0answers
10 views

MySQL Query - how to keep normal users from seeing staff posts? [migrated]

On my forum, I'm having an issue where non-staff members can view staff related posts that are otherwise hidden to normal users. Upon investigating I've discovered that staff related topics do not ...
1
vote
0answers
64 views

Is this pattern of optional dependency injection sound? [duplicate]

A lot of the time when working on legacy code bases, I find it hard to move manually created dependencies to the constructor parameters, because of a variety of reasons. Sometimes it's because the ...
2
votes
0answers
119 views

Deleting all cached page of the site [migrated]

Scenario Mobile and desktop version. I'm developing a website with a desktop and a mobile version: users can choose to switch version if they want to: javascript will save a cookie telling the ...
1
vote
1answer
100 views

Design pattern where decorated object may ask for things like “status updates” from the decorator to perform it's role?

Here's an situation that has haunted one of my open-source projects for quite some time. Imagine if you could represent every front-end input form with a single backend object? An object that ...
-2
votes
0answers
29 views

Not sure where to put the where clause In codeigniter [migrated]

I have been looking over the active records guide from codeigniters site and I am trying to figure where to put the where clause, in the model or controller? I think it goes in the model, but not sure ...
0
votes
2answers
81 views

Serving a file from a private directory [closed]

I have a PDF that needs to be accessible for multiple unrelated areas across a website. I don't want to reveal anything about where the file is downloaded from and I want to only upload the file once. ...
0
votes
2answers
45 views

What pattern do I use and how do I implement it for one method that will be handled multiple ways

My scenario: I am creating an application that will allow me to create a mapping of redirect url's that will point from the request url (the url in the old ecommerce solution) to the target url. There ...
0
votes
1answer
103 views

Change routing to comply with Law of Demeter

I have a Task, Owner and Plan. Charge values are kept in a plan, owner is on a particular plan and task knows its owner. A task needs to setup its charges based on the knowledge the owner has. Owner ...
2
votes
1answer
87 views

How to add permissions checks 'after the fact'

I have a great number of PHP classes which perform the business logic of my application, e.g. class FileMaker{ public function makeFile(){ //some code here to make a file } } Now I need to ...
-3
votes
0answers
18 views

PHP Help with Call to a member function add() on a non-object [migrated]

Question: What is the problem that I apparently cannot pass an object through to this method? Code: http://pastebin.com/fUbJdgXk Issue: Line 22 $this->business->add($specrep); returns Call to a ...
1
vote
3answers
137 views

Controller in MVC

Alright so it is an essential part of OOP that one class should only do one thing, and it makes sense. In practice I've seen that classes which don't obey this rule get thick and cluttered. So I was ...
1
vote
1answer
111 views

Does ORM at any point become a “requirement” for RESTful API?

I've started building a RESTful API in PHP's Slim framework. The framework appealed to me because of its light-weight design and routing features. I am using PostgreSQL for the database. However, ...
0
votes
1answer
85 views

Is this the template method pattern?

Could someone tell me whether the following is A) a good solution to the problem of repeating code and B) an example of the template method? Let's say I have one table, named VEHICLES, which I use to ...
0
votes
0answers
109 views

Is this a good implementation of the builder pattern?

I'm trying to design an SQL builder in PHP. I'm trying to make it so that the system could work with different database systems (e.g. Oracle, MySQL, MSSQL). Here's what I've got so far. First, I have ...