propel

Prevent Propel from inserting empty strings

不问归期 提交于 2019-12-10 19:29:53
问题 How can I prevent Propel ORM from inserting empty strings when a column is not set? CREATE TABLE user ( uid INTEGER PRIMARY KEY AUTO_INCREMENT, email VARCHAR(255) NOT NULL UNIQUE, -- No default value ... ) Engine InnoDB ... ; Propel allows $user = new User(); $user->save(); . I have tried setting SQL_MODE but it doesn't help. 回答1: The correct way to do this is with a validator in the schema and then a check using the validate() method in your code. Here's an example: <database ...> <table ...

Error after Upgrading FOS UserBundle from 1.2 to 2.0 in Symfony 2.1

给你一囗甜甜゛ 提交于 2019-12-10 17:34:50
问题 I have a project in Symfony 2.1, with PropelBundle, and FOS UserBundle. I upgraded FOS UserBundle with Composer from 1.2 to the latest version (2.0) and followed the instruction to delete the "propel_user_class" definition in the app/config/config.yml file as indicated in the Upgrade.md file. My new config is as follows: # FOSUserBundle Configuration fos_user: db_driver: propel firewall_name: main user_class: MyVendor\MyBundle\Model\Member registration: form: type: myvendor_user_registration

symfony 1.4 propel 1.6 : sum

自作多情 提交于 2019-12-10 15:44:19
问题 I'm trying to get a sum of columns in propel. My code $c = new Criteria(); $c->add(valuePeer::OWNER_ID, $this->getId()); $c->addSelectColumn('SUM(' . valuePeer::VALUE . ') as total'); $c->addGroupByColumn(valuePeer::VALUE); $sum = valuePeer::DoSelect($c); printing out $sum returns nothing (not even an empty object). all i get is Notice: Undefined offset: 1 in /.../lib/model/om/BaseValue.php on line 203 Notice: Undefined offset: 2 in /.../lib/model/om/BaseValue.php on line 204 I tried this

Propel: how to remove link made via many-to-many relation

谁说我不能喝 提交于 2019-12-10 12:13:19
问题 (link to previous question just in case: Struggling with one-to-many relation in an admin form) I have this many-to-many relation in my Symfony-1.3 / Propel-1.4 project between User and Partner . When the User is being saved, if it has certain boolean flag being true, I want to clear all the links to the partners. Here is what I do at the moment and it doesn't work: // inside the User model class public function save(PropelPDO $con = null) { if ($this->getIsBlaBla()) { $this-

Propel Single Table Inheritance Issue

大城市里の小女人 提交于 2019-12-09 22:45:01
问题 I have a table called "talk", which is defined as abstract in my schema.xml file. It generates 4 objects (1 per classkey): Comment, Rating, Review, Checkin It also generates TalkPeer, but I couldn't get it to generate the other 4 peers (CommentPeer, RatingPeer, ReviewPeer, CheckinPeer), so I created them by hand, and made them inherit from TalkPeer.php, which inherits from BaseTalkPeer. I then implemented getOMClass() in each of those peers. The problem is that when I do queries using the 4

Symfony app - how to add calculated fields to Propel objects?

爱⌒轻易说出口 提交于 2019-12-09 06:25:05
问题 What is the best way of working with calculated fields of Propel objects? Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when using it on View A but not on Views B and C. The calculated attribute is a COUNT() of "Order" objects linked to my "Customer" object via ID. What I can do now is to first select all

Could not find input file symfony

我与影子孤独终老i 提交于 2019-12-08 13:41:50
问题 I am able to generate bundle. But I face problem when building model using propel. I tried php symfony propel:build-model to generate model but it throws error - could not open input file: symfony . php app/console cache:clear works fine for me. Will I have to set environmental variable for symfony too. I am on window 7 32bit machine. I am using symfony2. Any suggestion will be very helpful to me. 回答1: Use php app/console propel:build-model instead of php symfony propel:build-model . The app

FOSUserBundle extend propel User

拜拜、爱过 提交于 2019-12-08 05:45:24
问题 I'm using FOSUserBundle and Propel in a Symfony 2.2 project. I'm trying to extend the User class and add a new method to it like so: namespace Acme\UserBundle\Model; use FOS\UserBundle\Propel\User as BaseUser; class User extends BaseUser { protected $id; public function __construct() { parent::__construct(); // your own logic } public function hasPermission($topic) { // TODO check if $topic has permission return TRUE; } } The problem is that when calling $this->getUser() in a controller, the

Propel 1.6 - Configuration Example?

◇◆丶佛笑我妖孽 提交于 2019-12-08 04:57:16
问题 I'm new to using Propel ORM. I have generated code and am now trying to integrate the runtime with my PHP project. I am struggling with initializing the main Propel class. It appears that the usage should be: require_once('propel/runtime/lib/Propel.php'); Propel::configure('/path/to/runtime/config.php'); Propel::initialize(); I cannot find any documentation on what the contents on the runtime configuration should be, other than this: http://www.propelorm.org/wiki/Documentation/1.6

FOSUserBundle extend propel User

天大地大妈咪最大 提交于 2019-12-08 00:25:29
I'm using FOSUserBundle and Propel in a Symfony 2.2 project. I'm trying to extend the User class and add a new method to it like so: namespace Acme\UserBundle\Model; use FOS\UserBundle\Propel\User as BaseUser; class User extends BaseUser { protected $id; public function __construct() { parent::__construct(); // your own logic } public function hasPermission($topic) { // TODO check if $topic has permission return TRUE; } } The problem is that when calling $this->getUser() in a controller, the class of the object returned is FOS\UserBundle\Propel\User , so hasPermission() is undefined. I tried