Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 25 10:48
    mringler edited #1917
  • Nov 24 15:37
    mringler synchronize #1917
  • Nov 24 15:26
    mringler synchronize #1917
  • Nov 24 15:10
    mringler synchronize #1917
  • Nov 24 14:54
    mringler opened #1917
  • Nov 22 08:01

    dereuromark on master

    Add support for native UUID col… (compare)

  • Nov 22 08:01
    dereuromark closed #1915
  • Nov 21 23:02
    dereuromark edited #511
  • Nov 21 23:02
    dereuromark opened #511
  • Nov 21 23:00
    dereuromark closed #243
  • Nov 21 23:00
    dereuromark closed #218
  • Nov 21 23:00
    dereuromark closed #185
  • Nov 21 23:00
    dereuromark closed #184
  • Nov 21 23:00
    dereuromark closed #177
  • Nov 21 23:00
    dereuromark closed #172
  • Nov 21 23:00
    dereuromark closed #167
  • Nov 21 22:59
    dereuromark closed #164
  • Nov 21 22:59
    dereuromark closed #125
  • Nov 21 22:59
    dereuromark closed #242
  • Nov 21 22:59
    dereuromark closed #358
J Skoba
@SpikedCola
Hi @k-hasan-19 , can you share your database schema.xml ?
in addition to setting auto-increment in the db, you also need to set it in schema.xml , like so:
<column name="id" phpName="Id" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" autoIncrement="true" required="true"/>
(and then run propel build of course!)
Ian Middelkamp
@ianmiddelkamp
Hello! new to this group. I have been having some trouble implementing multiple databases. I have been successfully using propel for a couple weeks with one database, but I want to add another into my models. I was able to create a secondary schema file using the reverse command, but I don't know how to set up my config file or other files that I need to change.
Ian Middelkamp
@ianmiddelkamp
Currently I have two schema files, one called schema.xml, and another quotes_schema.xml
my propel.yml, and config.php are as follows:
Ian Middelkamp
@ianmiddelkamp

##propel.yml
propel:
    database:
        connections:
            default:
                adapter: mysql
                dsn: mysql:host=localhost;port=3306;dbname=accounts
                user: office
                password: --PASSWORD--
                settings:
                    charset: utf8


###generated-conf/config.php

<?php
$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();
$serviceContainer->checkVersion('2.0.0-dev');
$serviceContainer->setAdapterClass('default', 'mysql');
$manager = new \Propel\Runtime\Connection\ConnectionManagerSingle();
$manager->setConfiguration(array (
  'dsn' => 'mysql:host=localhost;port=3306;dbname=accounts',
  'user' => 'root',
  'password' => '',
  'settings' =>
  array (
    'charset' => 'utf8',
    'queries' =>
    array (
    ),
  ),
  'classname' => '\\Propel\\Runtime\\Connection\\ConnectionWrapper',
  'model_paths' =>
  array (
    0 => 'src',
    1 => 'vendor',
  ),
));
$manager->setName('default');
$serviceContainer->setConnectionManager('default', $manager);
$serviceContainer->setDefaultDatasource('default');
and the first line of my secondary schema is <database name="quotes" defaultIdMethod="native" defaultPhpNamingMethod="underscore">

using propel model:build command, i get the following error ```
In GeneratorConfig.php line 225:

Invalid database name: no configured connection named quotes. ```

J Skoba
@SpikedCola
Hey @ianmiddelkamp I think you can accomplish this by defining a quotes connection in your propel.yml file. So where you have connections: default: ... you would duplicate the default:... block, change default to quotes, and update connection params accordingly.
Then when you regenerate config.php you should have two database connections, and the models will use the appropriate connection automatically.
Ian Middelkamp
@ianmiddelkamp

@SpikedCola Thanks for getting backed to me. I have added the next connection item as per your instruction. I think the part that I am missing is the regeneration of the config.php. I found in the documentation that the command config:convert, should create the config file. When ran this command, I get the same config.php file as posted above. There is no reference to the quotes configuration. Running model:build gives the same error as above. The documentation reads 'The config:convert command reads the runtime section of the configuration file and generates the relative PHP script." So I think I am just missing a run time section for my propel.yml file. So then I added a run time section:

propel:
    database:
        connections:
            default:
                adapter: mysql
                dsn: mysql:host=localhost;port=3306;dbname=accounts
                user: office
                password: ---PASSWORD---
                settings:
                    charset: utf8
            quotes:
              adapter: mysql
              dsn: mysql:host=localhost;port=3306;dbname=quotes
              user: office
              password:  ---PASSWORD---
              settings:
                  charset: utf8
    runtime:
      defaultConnection: default


      connections:
         - default 
         - quotes

But after, running config:convert again, there still is no change to the config.php file.

My sincere thanks for your time.

Ian Middelkamp
@ianmiddelkamp
@SpikedCola I got it to work! when I was running config:convert, I was in the wrong directory. Thanks for your time!
J Skoba
@SpikedCola
@ianmiddelkamp Glad you were able to get it working!
Ian Middelkamp
@ianmiddelkamp
Have a question about doing joins across these databases now. Do I need to do two separate queries to join tables across databases? It looks like the generated classes don't have set, get, etc. functions for querying across databases.
J Skoba
@SpikedCola
@ianmiddelkamp I never figured out how to do this with propel's model classes. I ended up writing a few raw sql queries to do joins across databases. Maybe someone else has some more helpful information
Ian Middelkamp
@ianmiddelkamp
@SpikedCola Or if is not a huge sql request, get one query from one connection, then convert to array, then merge the result of the other query converted to an array.
Kublai Gomez
@kublai_gitlab
Hi, considering that Propel 2 is in alpha release level, does anybody believes that we can use it in production environments?
Joseph W
@WillRun4Cake
Could someone please test the mailing list links on the Support page with a browser NOT logged in to their Google profile? When I click on either mailing list Google says "content unavailable". Are these mailing lists meant to be publicly available?
image.png
J Skoba
@SpikedCola
@WillRun4Cake I get the same message that you are getting, not sure.
Marek Kraus
@gamelaster
Also, sandbox and xsd links are dead :-(
nederdirk
@nederdirk:matrix.org
[m]

Hi, considering that Propel 2 is in alpha release level, does anybody believes that we can use it in production environments?

at my employer we're surely using it in production, relying on our test suite and composer.lock for stability.

Elinah
@elirabalison
Hi guys, I have some issues when I try to generate a schema.xml
It's generated under a folder name generated-reverse-database but the file is broken. What can be the reason? Thank you
Jazzgeir
@Jazzgeir
Did you get any error messages after running propel database:reverse --namespace etc?
Murray Collingwood
@murraycollingwood
Hi, new here. Is this conversation still active?
Murray Collingwood
@murraycollingwood
Three days and not a single response????
Jazzgeir
@Jazzgeir
Yep, we're here; albeit slow conversation...
J Skoba
@SpikedCola
@murraycollingwood best not to ask to ask - just ask your question and someone will see it eventually :)
Murray Collingwood
@murraycollingwood
I solved my problem... I had a field called primary which worked in my Propel1.6, but it fails in Propel2 (reserved word, although there is no error message to indicate this).
image.png
Murray Collingwood
@murraycollingwood
Can anybody help explain why my IDE is unable to see the "setLogger()" function?
Murray Collingwood
@murraycollingwood
Or even better - can somebody share an example of how to log queries and responses using Propel2?
(I'm using vscode and Intelephense)
Murray Collingwood
@murraycollingwood
Question number 2: How do I process the output from this query (the following code doesn't work):
        $pdo = Propel\Runtime\Propel::getReadConnection(MY_DATASOURCE);
    $results = $pdo->query("SHOW COLUMNS FROM $table");
    foreach ($results as $row)
        $flds[$row["Field"]] = $row["Type"];
Jazzgeir
@Jazzgeir
Have you tried echo get_class($results) to see what kind of object you get in return?
Murray Collingwood
@murraycollingwood
image.png
It's an array, but the keys are no longer 'Field' and 'Type' as in Propel1.6. Propel2 only seems to provide a numeric key, 0 - 5. 0 = fieldname, 1 = type. I ended up with this code to capture the fieldnames and fieldtypes:
jassgeir
@jassgeir
That's strange: The Connection interface specify " * @return \Propel\Runtime\DataFetcher\DataFetcherInterface|\PDOStatement|false"...
Murray Collingwood
@murraycollingwood

Just upgraded to Propel2 and I'm having trouble accessing the PDO object.

The main issue is that I have a Sabre library (for processing CalDAV requests) that requires the PDO connection to my database as a parameter.

$server = new Sabre_CalDAV_Server($pdo, $public = true);

Initially I had used this option:

/* Database */
$pdo = Propel\Runtime\Propel::getReadConnection(SOBS_DATASOURCE);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

However that was passing a ConnectionWrapper object - not what I was after.
So I googled a whole lot and found this option:

/* Database */
$pdo = new \Propel\Runtime\Connection\PdoConnection('mysql:host=localhost;dbname=sobs', 'username', 'password');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

However even with this option I'm still getting an error, like this:

[13-4-22 5:52pm] [0]: Uncaught exception "TypeError" with message "Argument 1 passed to Sabre_CalDAV_Server::__construct() must be an instance of PDO, instance of Propel\Runtime\Connection\PdoConnection given

How do I extract the actual PDO object from Propel that I can pass to this function?

J Skoba
@SpikedCola
@murraycollingwood There's probably a better way, but you can access the raw PDO object using reflection
/* Database */
$pdoConnection = \Propel\Runtime\Propel::getReadConnection(SOBS_DATASOURCE);
$pdoConnection->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$wrappedConnection = $pdoConnection->getWrappedConnection();
// var_dump($wrappedConnection->pdo); // $wrappedConnection->pdo exists, but this doesnt work - $pdo is protected

$r = new ReflectionObject($wrappedConnection);
$p = $r->getProperty('pdo');
$p->setAccessible(true); // set property to public
$pdo = $p->getValue($wrappedConnection);

// these work
var_dump($pdo);
foreach ($pdo->query('select * from users') as $a) {
    var_dump($a);
    die;
}
J Skoba
@SpikedCola
although it may be less work to just make a new pdo object with propel's user, pass, database, etc...
Murray Collingwood
@murraycollingwood
@SpikedCola I'm inclined to use your solution above so that my dsn, username and password are all stored in just a single location.
J Skoba
@SpikedCola
@murraycollingwood If you were so inclined, you could extract the dsn, username, password from propel's connection manager:
$dataSourceName = 'default'; // from your propel config
$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();
$connectionManager = $serviceContainer->getConnectionManager($dataSourceName);
$configuration = $connectionManager->getConfiguration();

var_dump($configuration); 
/* eg. array(6) {
  'dsn' => string(49) "mysql:host=127.0.0.1;port=3306;dbname=zzzzzzzzz"
  'user' => string(4) "root"
  'password' => string(10) "xxxxxxxx"
  ...
 */
Murray Collingwood
@murraycollingwood
@SpikedCola This is a much cleaner option. Thank you for your help.
turtlexiv
@turtlexiv
I have a query that I've had to convert into raw SQL (unless there is a practical way to do a UNION with the normal query methods). My previous code was using paginate() to terminate the query and get the results; now that I'm converting it to use raw SQL, is there a handy way to deal with pagination?
William Lang
@williamlang

Recently updated to beta2 -- having issues running model:build now -- getting errors that my TableMap classes are no longer compatible. I tried moving my old TableMap classes out only for Propel to return an error that the classes are not found. Shouldn't model:build ignore that these are missing and instead just... generate new models/table maps?

PHP Fatal error: Declaration of Model\Map\ActionTableMap::initialize() must be compatible with Propel\Runtime\Map\TableMap::initialize(): void in Model/Map/ActionTableMap.php on line 246

James Kingdom
@JamesKingdom
Hi, I've followed propel init, and on my first page that requires autoload.php and generated-conf/config.php, trying to load it is giving PHP Fatal error: Uncaught Error: Class '\\thi\\Map\\AuthorTableMap' not found in /var/www/thimbles/vendor/propel/propel/src/Propel/Runtime/Map/DatabaseMap.php:115\nStack trace:\n#0 [internal function]: Propel\\Runtime\\Map\\DatabaseMap->addTableFromMapClass('\\\\thi\\\\Map\\\\Author...')\n, any ideas?
jassgeir
@jassgeir
William Lang: Run config:convert first, then model:build. Should work.