0

Previously our zend 1.1 application was working with PHP 5.3 and Apache 2.2 versions and now we have upgraded our PHP to version 5.4 and Apache to 2.4

After this upgrade Zend's WHERE clause is not working with question mark (?) even it is not showing any error or warning. Example is given below:

$query = $db->select()
                ->from(array('users' => 'users'),
                       array('id' => 'id', 'email', 'fname'))
                ->where('email = ?', $email);

However it is working with without ? mark.

What is missing can anyone suggest because it is very critical for us.

Thanks

Johan
  • 74,508
  • 24
  • 191
  • 319
  • Define 'not working'. And what does the query look like if you do `echo $query`? – Tim Fountain Jul 18 '14 at 18:08
  • If i print the query it doesn't display anything but if i removed "?" mark from where clause and write the query something like this then it prints the query and working properly: ->where("email = '".$email."'"); – Yashpal Singh Jul 18 '14 at 18:31
  • 1
    "Doesn't display anything" sounds like there's an error that's happening but isn't being displayed due to your PHP settings. Can you check the error log to see if there's anything in there? – Tim Fountain Jul 18 '14 at 18:39

1 Answers1

0

Like @TimFountain noted, turn on php errors.

Code should be:

$query = $db->select()
            ->from('users', array('id', 'email', 'fname'))
            ->where('email = ?', $email);

Or

$query = $db->select()
            ->from('users', array('id', 'email', 'fname'))
            ->where('users.email = ?', $email);

Or

$query = $db->select()
            ->from('users')
            ->columns(array('id', 'email', 'fname'))
            ->where('email = ?', $email);

Or

$query = $db->select()
            ->from(array('u' => 'users'), array('id', 'email', 'fname'))
            ->where('u.email = ?', $email);

Or :)

$query = $db->select()
            ->from(array('u' => 'users'))
            ->columns(array('id', 'email', 'fname'))
            ->where('u.email = ?', $email);

Resources

Gerard Roche
  • 6,162
  • 4
  • 43
  • 69