Server side php with MSQL, calculated string field error
Server side php with MSQL, calculated string field error

I have been trying to create a calculated field in the PHP on the server side which is basically concatenating street name address number and address2 if not null
I have been breaking it down into different parts and seem to get stuck with it comes with the escape characters
Editor::inst( $db, 'Addresses', 'AddressAID' )
->fields(
Field::inst( 'streetname' ),
Field::inst( 'addressnumber' ),
Field::inst( 'address2' ),
Field::inst( 'city' ),
Field::inst( 'state' ),
Field::inst( 'ward' ),
Field::inst( 'district' ),
Field::inst( 'addressnotes' ),
Field::inst( 'nors' ),
Field::inst( 'lat' ),
Field::inst( 'long' ),
Field::inst( 'addressinactive' ),
Field::inst( '(select trim([StreetName]) + CHAR(32) + CONVERT(varchar(4), [addressnumber]) + COALESCE([address2], \"\") )', 'FullAddress' )
)
->process( $_POST )
->json();
DataTables warning: table id=Adresses - An SQL error occurred: SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near '\'.
I have experimented with \" and \'
This question has accepted answers - jump to:
Answers
I'm not familiar with PHP but you could render the combined columns client side using
columns.render
like this example.someone else will probably help with the PHP if you still want to go that route. You can add
.Debug(true)
before.Process()
to see the generated query. Use the browser's network inspector to view the JSON response. See the debug() docs for more details.Kevin
like this?
I suspect you don't want the
;
followingdebug(true)
. But I believe that is how its supposed to be used.Kevin