PS .. you shouldn't necessarily write your own SQL for Propel .. you shouyld
try using the Criteria objects rather as hand writing your own SQL breaks
the whole ORM database abstraction that Propel provides anyways

On Thu, Mar 26, 2009 at 9:36 AM, Gareth McCumskey <[email protected]>wrote:

> Are you complaining about the need to use model constants for table names?
> The entire structure of Propel and its model naming scheme is meant for
> development eas and maintainability not necessarily for dynamic table names.
> For example, if right near the end of the development period you suddenly
> realise that it would be better to turn one column you may have had into a
> normalised table and rather store ID's in that old column than the data you
> used to.
>
> One problem. You have coded that table name explicitly into all your
> methods and saved all that data into teh wrong table. With propel you can
> easily right your own methods to catch any calls your already developed code
> may have made to this old column and alter it accordingly instead of having
> to go through your potentially complex application and find all references
> and change all your queries manually to reflect the new schema.
>
> The reason to write queries "that way" is to allow you to accomodate
> changes in your schema without totally having to re-write everything that
> came before
>
>
> On Thu, Mar 26, 2009 at 9:19 AM, Benjamin <[email protected]> wrote:
>
>>
>> This question may be unrelated to symfony, and more related to
>> database abstraction, but I'm wondering why I should pull the table
>> names from the model.  I've been programming for a long time and have
>> never seen anyone need to use dyamic table names except when they have
>> prefixes on them that can change.
>>
>> So, this is a pain to type out:
>>
>> public static function getUserLabelsWithPasswordCounts($userId) {
>>    $query = "SELECT
>>                " . PasswordLabelPeer::NAME . ",
>>                (SELECT COUNT(*) FROM " .
>> PasswordLabelPasswordsPeer::TABLE_NAME . " WHERE " .
>> PasswordLabelPasswordsPeer::LABEL_ID . " = " . PasswordLabelPeer::ID .
>> ") AS pcount
>>              FROM
>>                " . PasswordLabelPeer::TABLE_NAME . "
>>              WHERE
>>                " . PasswordLabelPeer::ID . " = '$userId'
>>              ORDER BY
>>                " . PasswordLabelPeer::NAME . " ASC";
>>
>>    $con = Propel::getConnection();
>>    $pdo = $con->prepare($query);
>>    $pdo->execute();
>>
>>    return $pdo->fetchAll(PDO::FETCH_OBJ);
>> }
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to