Welcome Guest, Not a member yet? Register   Sign In
Join Command Works in phpMyAdmin, but Hangs When Run via PHP?
#1

[eluser]Vik[/eluser]
I have a join command that was perfectly generated by CI:

Code:
select * from metal_desc join abbrev on metal_des.ndb_no = abbrev.ndb_no where long_desc like 'copper' order by long_desc

I ran it in the phpMyAdmin Query window, and it ran perfectly, and came back with the correct results.

But when I run it in CI, when it comes time to execute it in the _execute function in mysql_driver.php:

Code:
function _execute($sql)
    {
        $sql = $this->_prep_query($sql);
        return @mysql_query($sql, $this->conn_id);
    }
...it seems to halt PHP execution. The next line of code never runs. It's like PHP or MySQL is hanging.

Checking the server error logs for PHP, MySQL, and Apache, shows no errors.

When I run a Query in CI without the join command, like this:

Code:
select * from metal_desc where long_desc like 'copper' order by long_desc

...everything runs perfectly.

Does anyone have any notion what could be causing this?

Thanks in advance to all for any thoughts.



[Note - something's garbling the % signs in the mySQL code. It should say percent-sign "copper" percent-sign.]
#2

[eluser]alpar[/eluser]
you might pasted annother query, but in the above one you have a typo select * from metal_desc join abbrev on metal_des.ndb_no
you select from metall_desc and use metal_des.field , note that there is a 'c' missing!
#3

[eluser]Vik[/eluser]
[quote author="alpar" date="1187456817"]you might pasted annother query, but in the above one you have a typo select * from metal_desc join abbrev on metal_des.ndb_no
you select from metall_desc and use metal_des.field , note that there is a 'c' missing![/quote]

I was really hoping that was it when I read your post, but it turns out that was just a typo here, rather than in the actual PHP app.

I tried changing the PHP to this, hoping to get a PHP error message:
Code:
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return mysql_query($sql, $this->conn_id) OR die('Query failed: ' . mysql_error());
// return @mysql_query($sql, $this->conn_id);

I ran the $sql query with the join command - and execution hung, without generating an error message.

I then shut down the Apache and mySQL servers, and immediately got the error message:

Code:
Query failed: Server shutdown in progress

...so the system was still alive and working - it seems like it was just waiting for something. What could be causing this?
#4

[eluser]Vik[/eluser]
It was because the fields weren't indexed! I indexed them and it works now.

It's odd that the exact same Join query ran immediately in phpMyAdmin before the fields were indexed. Hmmmm......




Theme © iAndrew 2016 - Forum software by © MyBB