Tag Info

New answers tagged

0

You can query which projects or task have changed? -->Yes Then I would iterate over all this items, extract the users and build an inmemory-table, where for every user the changed items are registered. Then I iterate over the users, get the items I want to add into the mail, build the mail and send it.


0

The error message tells a subquery returns multiple rows where it can deal only with one. Your subqueries (assuming you gave the complete statement) are SELECT SUM(prods .`existencia`) FROM productos prods WHERE prods.`iddocumento` = docs.`iddocumento` and SELECT prods.`precio` * prods.`existencia` FROM productos prods WHERE prods.`iddocumento` = ...


5

If you hate PHP so much, you should avoid developing web applications to be hosted on PHP servers. Even if there would be any SDKs (and I don't know any), you would still need to to spend a great amount of time reading PHP—for example when debugging the application. The same applies for language translators or supersets. A few years ago, I was working on a ...


1

By using a framework: You're leveraging work that others have already done. You're embracing the architectural/coding philosophy of the framework. You have to decide whether these two things are worth the learning curve required to adopt them. Given that PHP is your chosen language, I'd say that any help you could get from the outside would be ...


0

Not as such... At least, none that I can find/think of. However, docblocks commonly follow a distinct format/pattern: /** * Summary * [optional blank line] * Description * [optional blank line] * @see Optional, but more documentation can be added here * [optional blank line] * @todo: Development docs here * [optional blank line] * @api indicator of ...


-2

The answer is to use regular expressions. I asked this question because was a little bit confused with examples: they all use one-lined regexps and test string. As stated on http://ua2.php.net/manual/en/function.preg-match.php (Example #4) PHP's preg_match actually supports a "named sbpatterns": preg_match('/(?P<name>\w+): (?P<digit>\d+)/', ...


0

Yes, don’t use generic names unless this would result in ugly code, such as 600 menu item functions. In practice, it depends. If the function really is generic - it doesn’t have any if-statements for logic that depends on the kind of menu item - then addMenuItem is a good name, because that’s what it does. If the function contains menu item-specific ...


0

First of all, using too many <script> tags that link to or refer to any other file is a bad practice. Because the more the number of link to external resources, the more will be your http request which will slow your website down. When a site is launched to production environment, generally all the different css files are merged into one (keep in mind ...


0

If your database class is responsible for getting data into and out of your actual database, then it should take care of defending against SQL injection attacks or, if you're still building dynamic SQL, escaping character sequences that can be harmful (e.g. single quotes, line breaks (in some cases), etc.). That way, everything outside of the database ...


0

Your database validations should happen in your model. Assuming you are not using a framework you can write a generic wrapper class with your CRUD operations and protect against SQL injection etc. here. Data validation can occur within your wrapper and more specific validation (e.g. like Rails like validates_presence_of) on data can occur in models that ...


1

Think about the level of abstraction. A developer who uses AuthenticationService class doesn't care if, under the hood, the class is using cookies, session, database or some magical parameters within an URI. It makes sense to have both findLoggedInUser() and loginUser() in the same class. The class itself, on the other hand, relies on a lower abstraction: ...


2

A View should not touch cookies. The place of the stored data (cookie, database, user table) is an implementation detail that a view should not know about, basically a CRUD object. Also registerUser($email, $remember = false) is not a good method signature. What if you have to pass more data for one the cases later? This is hard to extend. Write different ...


3

The sigil for a variable in php is part of how the system works. It conveys some information for the parser about what the thing actually is. By keeping the variables and the functions in completely different name spaces, it allows one to have variable names that are function names without collision. The without collision bit is kind of important in php, ...


3

It would probably break tons of existing code. Using the sigil means variables may use the same names as keywords, functions (built-in or user-defined), classes, etc.


3

Good obfuscators will store the mapping between original names and obfuscated names, and provide a tool for reversing this obfuscation in stack trace dumps which appear in your logs. The mapping won't ever go on the server, so no one but the owner of the code can perform the deobfuscation. This is similar to the debug symbols which compiled languages use ...


5

Maintain two identical hardware/software platforms: a production platform and a test platform. When an error occurs, reproduce it on the test platform. Then, upload the unobfuscated code to the test platform and reproduce the bug again. Perform the usual troubleshooting, fix the bug, obfuscate the new code, and upload it to the production server.


2

Although the use of conjunctions often indicates a violation of the SRP, in this case it is just indicating the return value of a poor man's algebraic data type that can be one of two values, either null or a "success" value. They are using a kind of Hungarian Notation to compensate for weaknesses in the type system, namely a lack of non-nullable types. In ...


1

In my code I sometime create method pairs with names like getEntity() and getEntityOrNull(). The name makes the expected behavior clear. If getEntity() finds no entity then an exception is thrown. getEntityOrNull() will return a null. By doing this, the calling code becomes a bit clearer. If the calling code has to have an entity then getEntity will do ...


5

They are probably doing so because of naming conflicts. I assume that you cannot have two methods named getEntity, one which possibly throws an exception and one which returns null. Therefore, you have to name them accordingly. I, for one, dislike the practice of having many different ways of calling the same method unless it is performing some ...


0

Your two arguments are sound. But if they're the ones in charge of deciding the naming convention, try not to feel too bad about it being something you don't agree with. While you're at it, you should convince them not to use the "get" and "set" portions unless those methods actually do directly set or get a member variable.


1

To your first question: it is quite normal that each command contructor may have a different signature with different dependencies, so constructing the commands cannot be done fully generic. Using a DIC can indeed mitigate this. For more complex scenarios, you could also use the "abstract factory" pattern, where you have one factory class per command, all ...


7

You should definitely go with developing on localhosts (or your own separate vhosts on the server - to be sure you run the application under the same environment) and push-pull changes to the production environment only from VCS. Otherwise why use a VCS at all? Just for the fun of it and as a redundancy for tour code? Version-control systems are ...


3

I suggest you read the Git book - http://git-scm.com/book You need to commit your changes after you make them and push the data to bitbucket. Once you have done this your partner can fetch the changes from Bitbucket and merge the changes, before repeating the process. Version Control is designed to prevent you overriding each others code but you must ...


1

Let's explore the differences between using an interface vs a base class: If I'm using an interface, that means I need to also implement the, for example, connection logic for each class which wants to connect to the DB. That is a huge pain. However, if I just subclass a base class (which already provides connection method), then I don't need to keep on ...


1

Depends on a few more details you don't give, eg expected size of data. But in general I would most likely go for a)i) a)ii) would only be an option if you would talk about some database system that has special features to store and query this like some NoSQL databases (and maybe Postgres to some degree), having the option to actually query this data and ...


3

a) ii) is pure idiotic, evil stupidity. Don't. a) is better if you want to code the simplest possible thing (which is usually a very big 'want'). b) is better if you're pressed for database space or absolutely have to minimize DB access time, and don't care about the additional logic your code needs to retrieve the numbers. (Cell phone numbers aren't that ...


2

Your question is a bit confusing, but from what I understood, you need to refactor the code and find time to pay off the technical debt. someone wants student information, and I query Students and Classes in my Student class, if I put it in Classes, I cross over to the Students, [edit] violating single responsibility. Writing code is just easier part ...


4

Yeah, don't do that. A typical approach would be to have a LoadUser($user_id) function. It will return a user with all its attributes loaded from the database. Hence, load all the attributes of the object when you first create it, don't try to lazily load each attribute one at a time. It will be simpler and more efficient. When you want to save it, either ...


3

No, not really. It's clearly got two independent paths. It would be better to separate them into two (possibly overloaded) functions to better decouple them. Better yet, I would look to eliminate the name specific behavior unless it's really that common. What happens if you want to find errors since Thursday? What about errors that contain the word ...


3

REST does not mean to not use URL params at all. Your example demonstrates this very well. You can still see a 'search' as a REST resource. You implement a controller for it, though it only has one or two actions. (But details do not matter much in this case) Everything data needed to perform the search can then be sent by using params. There is nothing ...


0

Try the following. Worked for me. Form names must equal to database column names Get the values as below: foreach ($_GET as $formName => $value) { $sql = mysql_query("UPDATE table_name SET $formName = '$value' WHERE ID= $id"); } You will first need to insert an ID before the foreach loop. you can get next id by doing: SELECT MAX(id) FROM ..... ...


1

What I think @SlappyTheFish is getting at in his comment is that with extension you're basically telling your code that a Season IS a Year. When in reality, a Season IS NOT a year, a year HAS seasons. That's basically the reference to is-a and has-a that he had mentioned. Now looking at encapsulation you would have: 1 year object 4 Season Objects, ...



Top 50 recent answers are included