php

Is there a performance difference between PDO fetch statements?

like in /* Exercise PDOStatement::fetch styles */ print("PDO::FETCH_ASSOC: "); print("Return next row as an array indexed by column name\n"); $result = $sth->fetch(PDO::FETCH_ASSOC); print_r($result); print("\n"); print("PDO::FETCH_BOTH: "); print("Return next row as an array indexed by both column name and number\n"); $result = $sth->...

Doctrine Many-to-Many relationship between three tables

Hello, I have three tables: note, user and tag. Following is the diagram of the relationship between those tables: User can have many Notes and Tags, Note can have many Users and Tags, Tag can have many Users and many Notes. I have no problem setting many-to-many relationship between two tables, but can't manage to relate three table...

problem understanding relation mapping in doctrine 2

I read official documentation and tons of threads but still do not find solution for my situation. My case is very basic. I have 2 entities: comments and keywords for them. One comment can have many keywords but each keyword is only for one comment. Keywords are not unique in keyword table. So i decided this is one-to-many relation. Tabl...

I NetBeans, can I somehow store the RSA key fingerprint of the remote server or not have NetBeans confirm the key before taking action?

I'm currently using NetBeans 6.9 with the PHP plugin and a PHP Application from Remote Server project. However, every time I upload or download with it, I'm prompted with a warning that reads: The authenticity of host x can't be established. RSA key fingerprint is y. Are you sure you want to continue connecting? I'm connecting to m...

Question foreach on arrays returned by functions

i wonder if i do foreach (func_to_return_array() as $item) { ... } will it call func_to_return_array() many times (the array length)? if it does i guess it will be better to use $arr = func_to_return_array(); foreach ($arr as $item) { ... } ...

Ever Expanding Div to fit PHP/MySQL content.

I've created a blog main page using PHP and have included a sidebar and main area for the posts. When I add any more content to either the sidebar or the main content/posts area the content expands over the main div and the main div doesn't expand. How can I go about creating a div tag that will expand according to the content in the inn...

Problem with model loading in Zend Framework

I have weird problem with zend framework basics. I have simple action in IndexController: public function updateusersAction() { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); new Application_Model_Users(); } And a model I want to create is defined in application/models/Users.php ...

How do I build a page preloader for a php page?

Hi guys, I want to include a page preloader for all pages on my application. Something like what Gmail displays when its loading the entire page in the background. I don't want a prelaoding bar just the mechanism to display immediately a preloading message while the entire page loads in the background and upon successful load is displaye...

PHP coding problem.

I'm trying to display the apostrophe 's after the full name for example Samuel L. Jackson’s but if the last name or middle name is left out the 's is not displayed right for example Samuel ’s can some one help me correct this problem? Thanks Here is the PHP code. if(!empty($first_name) || !empty($middle_name) || !empty($last_name)) {...

PHP connect via SSH tunnel to LDAP in other network

I'm developing website for my school. In that school we authenticate users via LDAP, so there was an idea to do the same via school-site. On that site everything is working perfectly, but during developing I need very often to test if such solution works, of not. In order not to commit my changes so often I want to test this site on my l...

User validation pattern in PHP with Smarty

I am using PHP and Smarty. I have a simple application that: Shows page header Checks if user is logged in -> check session Checks if user wants to log out -> then clear session If logged in shows a menu. If not logged in, then challenges user for id/password -> set session Shows page footer Now I want to add the following to header:...

How can I use PHP 5.3 Closures like We use Blocks in Ruby

How can I use PHP 5.3 Closures like We use Blocks in Ruby. I never used 'for' Loop in Ruby due to using Blocks with 'each' 'find_all' 'inject' Methods. How can I use PHP 5.3 Closures like Ruby Blocks and say bye-bye to 'for' Loops :) Like Between { and } is a Closure(or Block or Anonymous Function) fruit = %w[apple banana orange] frui...

Difference between GOTO and THROW?

Many people accused me recently for just mentioning a single word - "goto". It makes me wonder, why it is considered such a nasty word. I am aware of several previous discussions on the topic, but it doesn't convince me - some of the answers just says "it's bad" not even trying to explain and some bring reasons, irrelevant for scripting ...

Rendering Zend_Form errors

say i want to attach errors to my Zend_Form i found out the default decorators for forms do not include errors. so i tried adding my own ... in my Zend_Form class $this->setDecorators(array( 'FormElements', array('Errors', array('placement' => 'PREPEND')), 'Form' )); but if there are no form errors, i get Warning: h...

Convert a relative URL to an absolute URL with Simple HTML DOM?

When I'm scraping content from some pages, the script gives a relative URL. Is it possible to get a absolute URL with Simple HTML DOM? ...

Emulate ruby's inject() behavior in PHP

From this question here, I was writing an enum wrapper to have some methods that can be used with lambdas to somewhat emulate ruby's usage of blocks in enums. class enum { public $arr; function __construct($array) { $this->arr = $array; } function each($lambda) { array_walk($this->arr, $lambda); } ...

Code to detect current page

Is there a php or javascript code that can detect the current user's page and then add <a class="active"> to an item in a ul (my menu). I include my menu in my pages with PHP include so making change is easy; I only have to edit it once. But, with that method, I can't individually set each page to have a class="active". How can I do t...

Adapt code to my mySQL tables

I have a table, "jos_ezrealty" that has address, city, state fields and declat & declong for latitude and longitude. I need to adapt the code below (provided by google - http://code.google.com/apis/maps/articles/phpsqlgeocode.html) to work with my table. All of my address fields are filled, and half of my lat & long fields are filled. I ...

Temp-Files in Symfony-Cache folder

Hi, I'm using Windows on some production machines (IIS with FastCGI-PHP). Since the update of one SF-Project to 1.3.x I notice some strange problems. The Server is "collecting" Temp-Files in the config-cache folder of the applications. They are named like con1718.tmp and always containing the autoload-config-cache. The tmp-files are not...

CodeIgniter: How to disable "index.php" in URLs completely (disallow it if manually entered in URL)

I'm using codeigniter and have been able to use url's without "index.php" in there, but if I manually type in "index.php", the urls still work. I'd like to disable access to "index.php/controller" type urls in order to avoid duplicate content penalty from Google. Here is what my current .htaccess file looks like: Options +FollowSymLink...