ODBC Driver 13 for SQL server Incorrect syntax near FROM or Invalid object name

422 views
Skip to first unread message

Antonio Diaz

unread,
Jan 23, 2018, 10:20:38 PM1/23/18
to Fat-Free Framework
Hi:

Hope you guys can help me, I have an Azure DB that has not issues connecting to the framework, but when I try to connect to SQL Server 2012 using the mapper or directly sending the query, I got either one of the two errors: Incorrect syntax near FROM or Invalid object name 'Jobs'.

here is the error of the screen using the mapper with :

$this->load(array());
return $this->query;

PDOStatement: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near the keyword 'FROM'.

[lib/base.php:2178] Base->error()
[lib/db/sql.php:236] user_error()
[lib/db/sql/mapper.php:293] DB\SQL->exec()
[lib/db/sql/mapper.php:333] DB\SQL\Mapper->select()
[lib/db/cursor.php:178] DB\SQL\Mapper->find()
[app/models/kpi.php:10] DB\Cursor->load()
[app/controllers/kpiController.php:8] kpi->all()
[lib/base.php:1791] kpiController->showPlan()
[lib/base.php:1612] Base->call()
[index.php:11] Base->run()

or this error using;

$result = $this->db->exec("SELECT * FROM Jobs");
return $result;

PDOStatement: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid object name 'Jobs'.

[lib/base.php:2178] Base->error()
[lib/db/sql.php:236] user_error()
[app/models/kpi.php:12] DB\SQL->exec()
[app/controllers/kpiController.php:8] kpi->all()
[lib/base.php:1791] kpiController->showPlan()
[lib/base.php:1612] Base->call()
[index.php:11] Base->run()

the constructor is:
    public function __construct(DB\SQL $d1) {
        parent::__construct($d1,'Jobs');
    }

and the config file is:

d1_dns=sqlsrv:Server=10.156.11.20;database=
d1_name=thedatabase
d1_user=theusername
d1_pass=thepassword

the Controller.php has no changes and works for Azure, MySQL and Mongo but SQL Server 2012

Any ideas? 

Thank you in advance.

Antonio 

ikkez

unread,
Jan 24, 2018, 6:34:23 AM1/24/18
to Fat-Free Framework
which framework version are you using? and which SQL queries are generated? ($db->log())

Antonio Diaz

unread,
Jan 24, 2018, 9:24:29 AM1/24/18
to Fat-Free Framework
Ikkez:

Thank you for your reply, 
The F3 version is 3.6.2
$db->log() : it doesn't go that far, the error is generated before the $db->log() instruction.

Antonio

Dennis Tobar

unread,
Jan 24, 2018, 9:28:50 AM1/24/18
to Antonio Diaz via Fat-Free Framework, Fat-Free Framework
Hi Antonio:

I had some similar problem in the past about the case letters in SQL Server. Just to confirm, is the Jobs table written in the same case in your database?.

Regards

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework+unsubscribe@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/9f507047-ca82-40de-a00f-457275a523bd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Dennis Tobar Calderón
Ingeniero en Informática UTEM

Antonio Diaz

unread,
Jan 24, 2018, 11:02:44 AM1/24/18
to Fat-Free Framework
ikkez:

I think I found the problem, my config file has 2 different servers that i want to use.

db_dns= azure db
d1_dns= SQL Server 2012

What I did, I switch and create the table that i was using in Azure -> SQL Server. and switch also the configuration, so now my config reads this way

db_dns= SQL Server 2012
d1_dns= azure db

And it worked! what I did wrong, was calling the wrong database in the controller file. I was calling the wrong database from the controller to the module

 $kpis = new kpi($this->d1);

the d1 was db.

Sorry for the confusion and the time wasted on my mistake, Great Framework btw.... love it!

Antonio
Reply all
Reply to author
Forward
0 new messages