dbal

symfony2.6 doctrine2 schema_filter parameter not exists

拜拜、爱过 提交于 2019-12-11 02:54:29
问题 I am using symfony 2.6 (composer.json equal to its github repo) and I am trying to use the schema filter of DBAL. in config.yml # Doctrine Configuration doctrine: dbal: schema_filter: ^sf2_ but error returned on shell: [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized option "schema_filter" under "doctrine.dbal" What am I missing? EDIT: config.yml (doctrine part only) doctrine: dbal: default_connection: default connections: default: driver: "%database

Doctrine custom data type

家住魔仙堡 提交于 2019-12-09 15:26:48
问题 I'm developing application with Symfony2. Symfony2 is using Doctrine 2 for DBAL and ORM. As far as I know Doctrine2 doesn't have suport for BLOB data type. However I want to implement BLOB support through the custom data type mapping: http://www.doctrine-project.org/docs/dbal/2.0/en/reference/types.html However I'm struggling to understand where should this part go. <?php Type::addType('money', 'My\Project\Types\MoneyType'); $conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney',

Symfony / Doctrine UnitTests with SQLite memory DB

拟墨画扇 提交于 2019-12-09 11:36:13
问题 I'm still working on PHP unit tests for testing my symfony2 controllers. My test classes are derivations of WebTestCase and the tests are doing GET or POST requests do check if everything works fine. I want to test all underlying layers, but I don't want to mess up my database with the tests. I don't want to use mock ups, but an in-memory SQLite db, where I can set up a test scenario to check all modifications. I found a lot of hints how to do this with doctrine 1.x, but they don't work any

Symfony : how to set SSL parameters in Doctrine DBAL configuration (YAML)?

天涯浪子 提交于 2019-12-09 06:44:59
问题 I'd like to add my SSL cert and key files to Doctrine DBAL configuration but I don't see how to achieve that. In PHP, I just have to write something like : $databaseHandler = new \PDO( 'mysql:host=my_host;dbname=my_db', 'username', 'password', array( \PDO::MYSQL_ATTR_SSL_KEY => '.../client-key.pem', \PDO::MYSQL_ATTR_SSL_CERT => '.../client-cert.pem', \PDO::MYSQL_ATTR_SSL_CA => '.../ca-cert.pem' ) ); I understand there is a Custom Driver Option driverOptions , and I saw this answer but I'm not

Incorrect mapping of mysql tinyint(2) as boolean with doctrine

隐身守侯 提交于 2019-12-07 02:51:52
问题 I reverse engineered my database with symfony2 and doctrine with commands : php app/console doctrine:mapping:convert php app/console doctrine:mapping:import php app/console doctrine:generate:entities But my field was mapped as boolean instead of tinyint(2). Why it is mapping as boolean? 回答1: tinyint (regardless of length) is mapped to type boolean in the MySQL DBAL platform. Also, consider that the entity generator is not a reliable tool: it was just meant to give you some help in getting

Symfony2 / Doctrine make $statement->execute() not “buffer” all values

流过昼夜 提交于 2019-12-05 02:32:56
问题 I've got a basic codeset like this (inside a controller): $sql = 'select * from someLargeTable limit 1000'; $em = $this->getDoctrine()->getManager(); $conn = $em->getConnection(); $statement = $conn->prepare($sql); $statement->execute(); My difficulty is that when the resultset is only a few records, the memory usage is not that bad. I echoed some debugging information before and after running the $statement->execute(); part of the code, and found for my implementation that I have the

Doctrine DBAL setParameter() with array value

余生颓废 提交于 2019-12-04 17:47:20
问题 I'm using doctrine DBAL and have some problem with SQL query as result of a queryBuilder. $builder = $this->getConnection()->getQueryBuilder(); $builder->select(['id','name','type']) ->from('table') ->where('id='.(int)$value) ->setMaxResults(1); $builder->andWhere($builder->expr()->in('type', ['first','second'])); echo(builder->getSQL()); $data = $builder->execute()->fetchRow(); And get SQL SELECT id, name, type FROM table WHERE (id=149) AND (type IN (first,second)) LIMIT 1 And this is the

Doctrine custom data type

牧云@^-^@ 提交于 2019-12-04 03:13:28
I'm developing application with Symfony2. Symfony2 is using Doctrine 2 for DBAL and ORM. As far as I know Doctrine2 doesn't have suport for BLOB data type. However I want to implement BLOB support through the custom data type mapping: http://www.doctrine-project.org/docs/dbal/2.0/en/reference/types.html However I'm struggling to understand where should this part go. <?php Type::addType('money', 'My\Project\Types\MoneyType'); $conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'money'); Is anybody was going through it? The reason I need a BLOB type is that I want to import

Enabling Doctrine DBAL commands in Symfony app/console

故事扮演 提交于 2019-12-03 16:35:47
When using bare-bone Doctrine with the command line that comes out of the box there are two commands available that don't seem to be available with using Doctrine with Symfony and the app/console : dbal dbal:import Import SQL file(s) directly to Database. dbal:run-sql Executes arbitrary SQL directly from the command line. Is there a way to enable these commands within Symfony's app/console ? I found a workaround for this, as you may call it that, or maybe rather just a way to enable the commands. By adding a Command to one of your own bundles (or a dedicated one, is up to you), you can simply

Symfony / Doctrine UnitTests with SQLite memory DB

喜夏-厌秋 提交于 2019-12-03 12:58:47
I'm still working on PHP unit tests for testing my symfony2 controllers. My test classes are derivations of WebTestCase and the tests are doing GET or POST requests do check if everything works fine. I want to test all underlying layers, but I don't want to mess up my database with the tests. I don't want to use mock ups, but an in-memory SQLite db, where I can set up a test scenario to check all modifications. I found a lot of hints how to do this with doctrine 1.x, but they don't work any more. So I want something like this: class BlahblahTest extends WebTestCase { public function testXXXYYY