php

PHP Doctrine ORM - How can I set the caching of data dependable on a variable

Hi, I want to use the caching from Doctrin ORM for PHP. In the model classes how Can I cache the results of the query depending on the value of a flag. I do not want to change the signature of the current methods... Is there a way to set a global variable for the Doctrine ORM and to check that doctrine variable inside the model classe...

Having multiple 'sets' of open files in Netbeans

I'd like to be able to have multiple "sets" of open files in netbeans but i didn't find a way or plugin to do it. Say i have 5 file related to "bug xyz" but i want to start working on feature "abc". Instead of having 10 files open i'd like to be able to say "create new set of files" and work on those and switch back and forth. Is there...

[PHP] Weird problem with dynamic method invocation

Hi everyone, this time, I'm facing a really weird problem. I've the following code: $xml = simplexml_load_file($this->interception_file); foreach($xml->children() as $class) { $path = str_replace('__CLASS_DIR__',CLASS_DIR,$class['path']); if(!is_file($path)) { throw new Exception('Bad configuration: file '.$path.' not f...

Methods / functions in php?

Hi, im pretty new to php comming from mostly java. Most of the PHP code i read, there is alot of duplication of code and almost never ever any local private methods. is there any reason for that? The only one i can come up with is if it has some performance issues? my clean code honor has a hard time leaving the code as it is. ...

How to get a random value from 1~N but excluding several specific values in PHP?

rand(1,N) but excluding array(a,b,c,..), is there already a built-in function that I don't know or do I have to implement it myself(how?) ? UPDATE The qualified solution should have gold performance whether the size of the excluded array is big or not. ...

HTML form with multiple submit options

Hi, I'm trying to create a small web app that is used to remove items from a MySQL table. It just shows the items in a HTML table and for each item a button [delete]: item_1 [delete] item_2 [delete] ... item_N [delete] To achieve this, I dynamically generate the table via PHP into a HTML form. This form has then obviously N [delete]-b...

How can I directly log in into phpBB3 from my website?

I integrated phpbb3 into my site.When a user login into my website then there is a tab called forum. If he clicks on the forum it will take to a page where it asking user name and password to login. But i want when the user clicks on the forum then he has to directly go to forum with his account details without logging again. Please hel...

Apache Rewrite Excluding Assets Directory

Hi all I'm writing a mini-MVC application. App architecture: actions/ templates/ site/ app/ styles/ images/ scripts/ So far, I've got a controller working properly, taking in all requests. However, javascript files are not being rendered properly in the browser; I'm getting a 404 Not Found when I try to load the ...

Multithreaded program in C: calculating thread stack space

Situation: I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created. Each thread forks - the child runs a PHP process via exec() and the parent waits for it to finish. Each PHP process takes the next item from a queue, processes it and exits. Basic code: http://www.4pmp.com/2010/03/mu...

Php 2d array as C# 2d array/struct

I'm using MailChimp's API to subscribe email to a list. Function listsubscribe() is used for email subscription: public static listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome) I downloaded ...

PHP ternary operator

($DAO->get_num_rows() == 1) ? echo("is") : echo("are"); This dose not seem to be working for me,I get an error "Unexpected T_ECHO" I have tried it with out the brackets around the conditional. Am I just not able to use a ternary operator in this way? The $DAO->get_num_rows() returns an integer value. Thanks ...

php run function on all images from one dir in recursive mode (noob)

hey guyz i have a function $result = create_watermark( 'input_file_name' ,'output_file_name'); i have dir called /images n have 500 images in it and all images are link images_(some_unknown_numbers).png (all png) now i want run them thru function in loop and want out put like /markedimage/images_1.png images_2.png images_3.pn...

How can I specify that Doctrine must use a mysqli-connection

Hi, while executing a long script that uses Doctrine to access the db, I get an error 2006 server has gone away. I've already solved this problem on a website that doens't use Doctrine. The solution there was to use mysqli instead of the normal mysql driver. How can i tell Doctrine to use a mysqli-driver in order to avoid 2006-errors? ...

An article and comments SQL query - efficient

Hi there, What'd be the most effective and efficient sql query to grab an article and the comments? It'd be two tables (articles, comments.) Would it be best to have it in one SQL query or two SQL querys? Speed is the main concern. Thanks in advance ...

One regular expression to match parts in various positions

Hi all, I'm trying to parse a DSN (from a Symfony application) using regular expressions, in order to link with a secondary application, but using the same database. The DSN I currently have is: mysql:dbname=my_db_name;host=localhost with a regex of: /^(\w+):(dbname=(\w+))?;?(host=(\w+))?/ (using preg_match()). This matches OK, ...

Paypal IPN security

Hello! I am developing a website which will allow users to pay via Paypal. Paypal IPN seems to be easy to integrate and it works on my localhost. Now the problem is that, the amount and the business name are passed to paypal using POST Data. I know it's very dangerous to put it that way, but I am not sure what are the alternatives. ...

Database INSERT does not take place

My code is as follows: <?php include("config.php"); $ip=$_SERVER['REMOTE_ADDR']; if($_POST['id']) { $id=$_POST['id']; $id = mysql_escape_String($id); $ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip'"); $count=mysql_num_rows($ip_sql); if($count==0) { $sql = "upd...

Differences between a while loop and a for loop in PHP?

I'm reading an ebook on PHP right now, and the author noted that the difference between a while loop and a for loop is that the for loop will count how many times it runs. So take this: <?php for ($i = 1; $i < 10; $i = $i + 1) { print "Number $i\n"; } ?> But wouldn't this be the same as <?php $i = 1; wh...

regular expression for matching number and spaces.

Hi all i want to create a regular expression which will allow only spaces and number.. And how can i check this with PHP? Thanks in advance Avinash ...

How to optimize indexing of large number of DB records using Zend_Lucene and Zend_Paginator

So I have this cron script that is deployed and ran using Cron on a host and indexes all the records in a database table - the index is later used both for the front end of the site and the backed operations as well. After the operation, the index is about 3-4 MB. The problem is it takes a lot of resources (CPU: 30+ and a good chunk of...