In precedenza tutte le mie query funzionavano correttamente in CI versione 2.0 ma quando ho aggiornato a 2.0.3 alcune delle mie query SELECT erano interrotte.Comportamento di backtick strano in Active Record in Code Igniter 2.0.3
CI sta aggiungendo automaticamente backtick (``), ma nella versione precedente è in esecuzione così com'è.
utente CI manuale sono incaricati di aggiungere secondo parametro in
DB-> selezionare
come
FALSE
ma ancora non funziona.
codice è il seguente: -
class Company_model extends MY_Model
{
----------------
$this->db->select(' count('.$fieldname. ') as num_stations');
$this->db->select(" CONCAT_WS(',', clb_company.address1, clb_company.address2, clb_company.city, clb_company.state, clb_company.zipcode) as companyAddress");
$this->db->from($this->_table);
$this->db->join($this->_table_device, $fieldname1. " = ". $fieldname2, 'LEFT');
$this->db->where($blablafield , '0');
----------------
L'errore è la seguente: -
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'FROM (`clb_device`) JOIN `clb_company` ON `clb_company`.`id` = `clb_device`.`com' at line 2
SELECT `clb_device`.`id` as deviceId, `clb_pricing_specifications`.`name` as pricingSpecName, `clb_company`.`name` as companyName, `clb_device`.`mac_address` as deviceMacAddress,
`clb_device`.`reseller_model_number` as deviceModelNumber, `clb_pricing_spec_grouping`.`pricing_master_spec_id` as pricingSpecId, `clb_device`.`address` as deviceAddress,
`clb_device`.`is_home` as deviceIsHomeCharger, CONCAT(clb_company.portal_line1, `'/'`, `clb_device`.`name)` as deviceDisplayName FROM (`clb_device`) JOIN `clb_company`
ON `clb_company`.`id` = `clb_device`.`company_id` LEFT JOIN `clb_pricing_group_devices` ON `clb_device`.`id` = `clb_pricing_group_devices`.`device_id` and clb_pricing_group_devices.is_active = 1
LEFT JOIN `clb_pricing_spec_grouping` ON `clb_pricing_group_devices`.`pricing_spec_id` = `clb_pricing_spec_grouping`.`pricing_master_spec_id` LEFT JOIN `clb_pricing_specifications` ON
`clb_pricing_spec_grouping`.`pricing_spec_id` = `clb_pricing_specifications`.`id` WHERE clb_company.vendor_id is not null AND cast(substr(clb_devi
ce.software_version, 1, 3) as decimal(2,1)) > 2.0 AND clb_device.device_state > 0 GROUP BY `clb_device`.`id` ORDER BY CONCAT(trim(clb_company.portal_line1), `'/'`, trim(clb_device.name)) desc LIMIT 20
Dai un'occhiata alla CONCAT (trim (clb_company.portal_line1), ` '/'` , trim (clb_device.name))
Per favore suggerire la soluzione alternativa.
Gracias
avrei pensato che gli apici inversi avrebbero fatto alcuna reale differenza per la query come faranno solo incapsulano i nomi delle tabelle/campi nella query per consentire i caratteri speciali se si utilizza 'echo $ this-> db-> last_query(); 'e pubblica il codice che potrebbe consentirci di fare più luce su di esso. – simnom
@simnom: crea un problema, ad es. CONCAT (trim (table1.field1), '/', assetto (table2.field2)) viene analizzato come CONCAT (trim (table1.field1), ' '/'', trim (table2.field2)) –
prega di inserire un Codice di registrazione attivo nella domanda. – Louis