开发者

Why does Codeigniters msqli driver return null as a query result while the mysql driver executes the query just fine?

I'm on a managed Server from 1and1 and i'm using stored procedures in my current Project. For that I have to use mysqli as the database driver.

1and1 wants to setup a开发者_运维百科 socket for database connections depending wether i use mysql (which is /tmp/mysql5.sock) or mysqli (/tmp/mysqld.sock).

When I setup my database.php to use the mysqli driver and the hostname with the respective socket my queries will fail and i get the following response as result object.

object(CI_DB_mysqli_result)#17 (7) {

["conn_id"]=> bool(false)

["result_id"]=> NULL

["result_array"]=> array(0) {}

["result_object"]=> array(0) { }

["current_row"]=> int(0)

["num_rows"]=>NULL

["row_data"]=>NULL

}

I've checked my phpinfo and it tells me, that mysqli is loaded and its parameter "default_socket" is "/tmp/mysqld.sock".

what am i missing?

The ["conn_id"]=> bool(false) thing seems like there is no database connection at all, am I right? How do i get mysqli connections to work with 1and1 in Codeigniter?

@edit: this is one of the queries i try to perform:

function getStreetByReference ( $plz)
{

    $query = $this->db->query("SELECT strasse from dwh_strassen WHERE dwh_strassen.PLZ =  '$plz' GROUP BY dwh_strassen.strasse");
    $temp_result = array();
    foreach ( $query->result_array() as $row )
    {
         $temp_result [] = $row;
    }
    return $temp_result;
}


Ok, long story short, the mysqli Driver from codeigniter does not support working with sockets. Or at least i could not find the right setting to do so.

I've added the parameter in the driver class and now it works.

in /System/database/drivers/mysqli_driver.php

if ($this->port != '')
        {
            return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port, $this->socket); // $this->socket is new, i've added the same variable in my database.php
        }
        else
        {
            return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
        }

and in /application/config/database.php

$db['live']['socket'] = "/tmp/mysql5.sock";

Thats propably all there is to it. I've done some testing and even if phpinfo tells me, that the default_socket for mysqli is not the mysql5.sock, it works just fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜