Hi there!
can anyone please help me how can I connect a trongate web app with postgresql instead of MySQL ?
Connection with POSTGRESQL
4 years ago
4 years ago
#1
4 years ago
#2
Hello,
I believe that you have to create your own module for postgresql.
Here is the a link to php manual.
https://www.php.net/manual/en/pgsql.examples-basic.php
I believe that you have to create your own module for postgresql.
Here is the a link to php manual.
https://www.php.net/manual/en/pgsql.examples-basic.php
4 years ago
#3
I have figured out a way to connect my web app with postgresql.
I had to simply changed the the driver name from my sql to pgsql in Model.php file
I had to simply changed the the driver name from my sql to pgsql in Model.php file
4 years ago
#4
That's great!
Just remember that when you update your trongate app, The model file will revert back to mysql.
So save a copy of your changes.
Dan
Just remember that when you update your trongate app, The model file will revert back to mysql.
So save a copy of your changes.
Dan
4 years ago
#5
** edited
I would suggest creating a pull request so Trongate can switch database use but it's not as easy as just creating a connection. There would have to be a lot of work put in to make this work in the framework and also the Desktop app...
for example, in the database.php:
then in model.php
Obviously, you would add the logic to include SQLlite as that one is
PDO supports 12 different databases:
MySQL
PostgreSQL
Oracle
Firebird
MS SQL Server
Sybase
Informix
IBM
FreeTDS
SQLite
Cubrid
4D
I would suggest creating a pull request so Trongate can switch database use but it's not as easy as just creating a connection. There would have to be a lot of work put in to make this work in the framework and also the Desktop app...
for example, in the database.php:
then in model.php
Obviously, you would add the logic to include SQLlite as that one is
PDO supports 12 different databases:
MySQL
PostgreSQL
Oracle
Firebird
MS SQL Server
Sybase
Informix
IBM
FreeTDS
SQLite
Cubrid
4D
4 years ago
#6
Thanks for your suggestion!I will do it as God willing.
3 years ago
#7
Hello,
Was a pull request done for this? Thanks.
Was a pull request done for this? Thanks.
3 years ago
#8
Yeah kinda, MFahad did make a pull request>
but it wasn't the detailed one I suggested and he didn't explain anything, so DC would have looked at this wondering WTF?
He just added a defined constant 'DRIVER' as a db type, with no explanation on its use in database.php:
There is no extra logic for SQLite or any of the other supported db types that can be used with PDO as I mentioned...
There would also have to be some changes in the Desktop app to accommodate different database types for this addition to be bulletproof.
but it wasn't the detailed one I suggested and he didn't explain anything, so DC would have looked at this wondering WTF?
He just added a defined constant 'DRIVER' as a db type, with no explanation on its use in database.php:
There is no extra logic for SQLite or any of the other supported db types that can be used with PDO as I mentioned...
There would also have to be some changes in the Desktop app to accommodate different database types for this addition to be bulletproof.
3 years ago
#9
I've posted a pull request for a quick change to SQLite . Hope it gets accepted.
3 years ago
#10
I am able to read from the sqlite db at this link
http://localhost/sqlite/
At this link I see this error. Any idea on why the error appears? Works fine if its a mysql db.
http://localhost/sqlite/contents/show/1
Fatal error: Uncaught Error: Call to a member function bindValue() on bool in \engine\Model.php on line 77
( ! ) Error: Call to a member function bindValue() on bool in \engine\Model.php on line 77
function prepare_and_execute($sql, $data) {
$this->stmt = $this->dbh->prepare($sql);
if (isset($data[0])) { //unnamaed data
return $this->stmt->execute($data);
} else {
foreach ($data as $key => $value) {
$type = $this->get_param_type($value);
$this->stmt->bindValue(":$key", $value, $type); // THIS triggers the error
}
return $this->stmt->execute();
}
}
Maybe a problem with bindValue and sqlite?
https://stackoverflow.com/questions/48514115/bindparam-bindvalue-not-working-with-my-sqlite3-prepared-statements
http://localhost/sqlite/
At this link I see this error. Any idea on why the error appears? Works fine if its a mysql db.
http://localhost/sqlite/contents/show/1
Fatal error: Uncaught Error: Call to a member function bindValue() on bool in \engine\Model.php on line 77
( ! ) Error: Call to a member function bindValue() on bool in \engine\Model.php on line 77
function prepare_and_execute($sql, $data) {
$this->stmt = $this->dbh->prepare($sql);
if (isset($data[0])) { //unnamaed data
return $this->stmt->execute($data);
} else {
foreach ($data as $key => $value) {
$type = $this->get_param_type($value);
$this->stmt->bindValue(":$key", $value, $type); // THIS triggers the error
}
return $this->stmt->execute();
}
}
Maybe a problem with bindValue and sqlite?
https://stackoverflow.com/questions/48514115/bindparam-bindvalue-not-working-with-my-sqlite3-prepared-statements