-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Query builder with table prefix after updating to 4.6.0 version #9424
Comments
Sorry, but I have not been able to reproduce the problem using the steps given: <?php
namespace App\Controllers;
use CodeIgniter\Database\RawSql;
class Home extends BaseController
{
public function index()
{
//return view('welcome_message');
$builder = db_connect()->table('employee as e');
$builder->select(['e.id','e.employee_number','e.employee_prefix','e.first_name','e.middle_name','e.last_name','e.is_deleted','e.contact_number','e.email']);
$builder->where('e.is_deleted',0);
$builder->join('location as l', 'l.id = e.location_id')->select('l.name as location_name');
$builder->select(new RawSql("CONCAT(`first_name`, ' ', `middle_name`,' ',`last_name`) as full_name"));
$builder->select(new RawSql("CONCAT(`employee_prefix`, '', `employee_number`) as full_number"));
dd($builder->getCompiledSelect());
}
} This gives me: SELECT `e`.`id`, `e`.`employee_number`, `e`.`employee_prefix`, `e`.`first_name`, `e`.`middle_name`, `e`.`last_name`, `e`.`is_deleted`, `e`.`contact_number`, `e`.`email`, `l`.`name` as `location_name`, CONCAT(`first_name`, ' ', `middle_name`,' ',`last_name`) as full_name, CONCAT(`employee_prefix`, '', `employee_number`) as full_number
FROM `h_employee` as `e`
JOIN `h_location` as `l` ON `l`.`id` = `e`.`location_id`
WHERE `e`.`is_deleted` = 0 Please provide a better explanation/example so that we can reproduce the problem. |
in .env file i gave database.default.DBPrefix = h_ then in query builder its throwing error h_e.is_delete is not a field in table |
database.default.DBPrefix = h_ is set - as you may see in the produced SQL. |
its fix .. its was showing because i was using datatable library error was due to it |
Thank you for the info. |
PHP Version
8.2
CodeIgniter4 Version
4.6.0
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
MySQL 5.6
What happened?
Its adding
database.default.DBPrefix = h_
in every filed and in where condition its adding the table prefix
event with the table
this is quire Builder
Steps to Reproduce
Expected Output
its should not add the h_ table prefix in where cause as i am using table alias
Anything else?
No response
The text was updated successfully, but these errors were encountered: