Method 'affected_rows' not found in CI_DB_query_builder
yokonrad opened this issue · comments
As the title says. Do you have any fix for that? :)
Yes.
If you are using the default mysqli driver is possible solve this adding the class CI_DB_mysqli_driver with her public methods in phpstorm.php. As follow:
class CI_DB_mysqli_driver extends CI_DB_query_builder {
/**
* Affected Rows
*
* @return int
*/
public function affected_rows()
{
}
/**
* Insert ID
*
* @return int
*/
public function insert_id()
{
}
/**
* Database connection
*
* @param bool $persistent
*
* @return object
*/
public function db_connect($persistent = FALSE)
{
}
/**
* Select the database
*
* @param string $database
*
* @return bool
*/
public function db_select($database = '')
{
}
/**
* Error
*
* Returns an array containing code and message of the last
* database error that has occurred.
*
* @return array
*/
public function error()
{
}
/**
* Returns an object with field data
*
* @param string $table
*
* @return array
*/
public function field_data($table)
{
}
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @return void
*/
public function reconnect()
{
}
/**
* Database version number
*
* @return string
*/
public function version()
{
}
}
And change the doc properties from CI_DB_query_builder
to CI_DB_mysqli_driver
. 😃
After you do it, mark the file system/database/drivers/mysqli/mysqli_driver.php
as text in PhpStorm IDE then will be possible see the mysqli methods by $this->db
.
You also can do this with other drivers. For me it works well.
It works well too if there is only affected_rows()
method inside CI_DB_mysqli_driver
:)
class CI_DB_mysqli_driver extends CI_DB_query_builder {
/**
* Affected Rows
*
* @return int
*/
public function affected_rows() {}
}
Do i need rest of methods inside CI_DB_mysqli_driver
? Anyway you should consider adding this to your project ;) I am working under newest CodeIgniter v3.1.3 and for now it looks like everything is good
// EDIT: I checked all of the methods and insert_id()
is not working too, so correct class should look like:
class CI_DB_mysqli_driver extends CI_DB_query_builder {
/**
* Affected Rows
*
* @return int
*/
public function affected_rows() {}
/**
* Insert ID
*
* @return int
*/
public function insert_id() {}
}
And now all of the methods works for me :)