Propel 2.0 model:build cannot find database - php

I'm trying to reverse engineer a database with Propel 2. But every time i try to run the model:build command i get the following error:
[Propel\Generator\Exception\InvalidArgumentException]
Invalid database name: no configured connection named 'default'
It says "no configured connection"?? but is was able to generate a schema.xml from the database with the "reverse" command?
Thanks in advance.

I found that I am having similar situation.
<database name="somename" ...>
Change the name attribute in <database> in the generated schema.xml to match the connection name in your propel.yaml may solve the problem.
database:
connections:
somename:
adapter: mysql

Related

Symfony 3.4 Command vs oracle wallet ORA-12154: TNS:could not resolve the connect identifier specified

I have a Symfony 3.4 application connected to an Oracle DB via a Wallet, so the configuration of the DB username and password are outside the app and of my control.
To let the application to work with this specific configuration I added in the config.yml, the parameter:
doctrine:
dbal:
connections:
default:
...
session_mode: !php/const OCI_CRED_EXT
...
The application works without any problem.
I have a sync function that connect to different DBs and sync some data.
The sync function can be run manually within the application UI and it works.
I wrote a console command to run in a cron job that instantiate the same set of classes used manually by the application but I got the error in object when I execute the command via terminal.
The exact error is:
In AbstractOracleDriver.php line 57:
An exception occurred in driver: ORA-12154: TNS:could not resolve the connect identifier specified
In OCI8Exception.php line 16:
ORA-12154: TNS:could not resolve the connect identifier specified
The same error occurs when testing the db connection with the console:
#php .\bin\console doctrine:query:sql "select sysdate,current_date from dual"
So, it seams that the console command in some way ignore that the oracle connection i made through a wallet and looks for servicename parameter which is, obviously, empty resulting in a TNS error.
Do someone have some suggestion on how to fix the issue?
Thanks,
Marco

Unable to load driver: com.mysql.jdbc.Driver

I try to use Jasper to generate report in Laravel. It's work perfect if I didn't use database, if I add database to get data from mysql database he gives me an error "Unable to load driver: com.mysql.jdbc.Driver". I install JDBC Connector and Setup ODBC connection to local mysql server:
Also I setup CLASSPATH to MySQL connector:
Because laravel print me that have some error to generate pdf with database connection I change it to print output command and ran it in terminal and he gives me an error that "Unable to load driver: com.mysql.jdbc.Driver", see next picture:
If you have ANY idea I will be grateful!
A lot of Java applications do not use the CLASSPATH environment variable, and it looks like jasperstarter is one of them.
Looking at http://jasperstarter.cenote.de/usage.html you need to use the command line option --jdbc-dir <directory with driver jar(s)>:
--jdbc-dir <dir> directory where jdbc driver jars are located. Defaults to ./jdbc
Alternatively, as you indicated in the comments, you can put the driver in the JasperStarter/jdbc folder, as that is the default location.

SQLite3 / PDO - No such table though it does exist

I have a problem with an SQLite3 database where I can access it either with the sqlite3 command or with the PHPStorm built-in database manager but the application I am working on doesn't find the tables in it. It correctly connects to the database it seems.
This line of PHP causes the PDOException:
$query = "SELECT * FROM users";
$results = self::$app->db->query($query);
And the exception is simply SQLSTATE[HY000]: General error: 1 no such table: users. I am using the Slim framework, by the way.
I don't really know what to do as I am new to Slim as well as SQLite.
Thank you for your help :-)
The database that you have opened does not contain this table.
SQLite will happily open any file name; if it does not exist, it will create a new, empty database.
Check your database file name.
Thanks to the accepted answer that pointed me in the right direction.
I am using Symfony 4.1 and realized that the base directory for Symfony is the public directory (should be app in 2.8) so to open my database I had to do :
# file: PROJECT_ROOT/.env
DATABASE_URL="sqlite:///../my_super.db"
But then, every call to doctrine in a command (like doctrine:schema:update) must be called in a direct subfolder of the project, like so:
PROJECT_ROOT/bin$ ./console doctrine:schema:update --dump-sql

Modify existing schema for SonataPageBundle: page__site doesn't exist

After finally(!) adding SonataPageBundle to an existing app I get when going to the dev environment
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'volunteer.page__site' doesn't exist
on running php app/console sonata:page:create-site. Nowhere in the documentation for the PageBundle is there any mention of how to create the schema.
If I do doctrine:schema:create --dump-sql to see what's what I get
[Doctrine\DBAL\DBALException]
Unknown column type "json" requested...
A search in the installed PageBundle directory (i.e., not at the Sonata-Project website) revealed the instruction to modify app/config/config.yml with
doctrine:
dbal:
...
types:
json: Sonata\Doctrine\Types\JsonType
With this addition the schema could then be updated and a site created.
If my sanity holds I'll fork the documentation to have it match a known good procedure.

Symfony Jobeet Tutorial Day 3, databases.yml error

I'm new to Symfony and I'm going through the Jobeet tutorial v1.4 for
Doctrine. I am currently stuck on Day 3. I've followed all the
instructions on configuring the database and building models and
modules; however, when I try to access
"http://localhost:8080/frontend_dev.php" I receive the following
error:
'Configuration "config/databases.yml" does not exist or is unreadable.'
My config/databases.yml file looks like this:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=localhost;dbname=jobeet'
username: root
password: mysecret
Creating the tables and loading the fixtures seem to work fine after checking the database with phpmyadmin. Any help would be appreciated.
Thank you!
I tried what's in the Jobeet from Day 1 to 3 and it works on my local machine, maybe what you have there is some file permission issue that is preventing your symfony to load the config/databases.yml so please change permissions as needed (chmod in linux).
Not sure if this will solve the problem but I think this is worth to try, execute php symfony cc or simply clear the cache folder and load up again your app in the browser, since the config/databases.yml is to be cached as config_databases.yml.php (you can take a look on /cache/frontend/dev/config/)
phpmyadmin? arrggggghhhhhhh =P
Anyway, your identation is wrong.
It should be like this:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: "mysql:host=localhost;dbname=jobeet"
username: root
password: mysecret
As for the error, if you're on a mac, change the permissions using chmod. :-)
If you're stuck on a problem with databases.yml, this symfony databases.yml configuration reference could be useful: www.symfonyreference.com/databases-yml

Categories