Blank spaces in MSSQL queries (WHERE clause)

QuestionsBlank spaces in MSSQL queries (WHERE clause)
Paolo D. asked 8 years ago

I'm making tests on master-detail.php and I noticed that this command:

// and use in sql for filteration
$grid->select_command = "SELECT CALL_ID, CALL_CLIENT_CODE, CALL_DATE FROM CALLS WHERE CALL_CLIENT_CODE = 'C 44 4'";

is passed omitting all blank spaces but one. I found it simply ordering by a non existing field, so that the following error could be shown:

Couldn't execute query. SQLState: 42S22 Error Code: 207 Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'CALL_IDx'. – select top (20+0) CALL_ID, CALL_CLIENT_CODE, CALL_DATE FROM CALLS WHERE CALL_CLIENT_CODE = 'C 44 4' ORDER BY CALL_IDx DESC

As you can see the variable 'C 44 4' has been changed to 'C 44 4'.

3 Answers
Paolo L. answered 8 years ago

It seems that posting this question had the same problem!

The variable 'C (10 spaces follows) 2' has been changed to 'C 2'

Abu Ghufran answered 8 years ago

It looks like inside lib, following line is causing this:

$this->select_command = preg_replace("/[ ]+/"," ",$this->select_command);

You can edit jqgrid_dist.php and comment it out.
It does not do any thing special except making readability of sql query.

Paolo L. answered 8 years ago

Yes, txs

Your Answer

6 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?