Skip to content
Advertisement

Execute raw SQL using Doctrine 2

I want to execute raw SQL using Doctrine 2 I need to truncate the database tables and initialize tables with default test data. Answer I found out the answer is probably: A NativeQuery lets you execute native SQL, mapping the results according to your specifications. Such a specification that describes how an SQL result set is mapped to a Doctrine

Static class initializer in PHP

I have an helper class with some static functions. All the functions in the class require a ‘heavy’ initialization function to run once (as if it were a constructor). Is there a good practice for achieving this? The only thing I thought of was calling an init function, and breaking its flow if it has already run once (using a

Replacing a specific part of a query string PHP

I use $_SERVER[‘QUERY_STRING’] to get the query sting. A example would be a=123&b=456&c=789 How could I remove the b value from the query string to obtain a=123&c=789 where b can be any value of any length and is alpha numeric. Any ideas appreciated, thanks. Answer The value is going to be $_GET[‘b’]. How about:

Preventing JavaScript Injections in a PHP Web Application

What are the measures needed to prevent or to stop JavaScript injections from happening in a PHP Web application so that sensitive information is not given out (best-practices in PHP, HTML/XHTML and JavaScript)? Answer A good first step is applying the methods listed in the question Gert G linked. This covers in detail the variety of functions that can be

Split a string array into pieces

Let’s say I have an array that store like this: How should I make the array[0] string split into piece by separated the “;”? Then I want to save them in array again, or display them out. How should I do it? Answer I would personally use the preg_split to get rid of that extra array element that would occur

PHP set warnings as fatal

Is there a way to specify in php.ini or apache level that the script execution should halt on any warnings? I tried searching through google and stackoverflow but couldn’t find any relevant …

Advertisement