Murray Collingwood | 2 May 2008 08:21
Picon
Favicon

Suddenly the peer methods disappeared

Hello

Something awful just happened and I'm not sure what to do....

My app uses two databases, caps and capext.

I've been working on a development system (WAMP) and building my app - everything was working beautifully.

I went to publish my app to my server (LAMP) and suddenly I get this message:
Fatal error: Call to undefined method OfficerPeer::selectall() in /home/www/static/caps/setup.php on line 7

I know everybody will ask to see this line of code, so....

$officers = OfficerPeer::selectAll();

Okay, and what about the Peer class...

class OfficerPeer extends BaseOfficerPeer {
   public function selectAll() {
        $c = new Criteria();
        $c->addAscendingOrderByColumn(self::USERNAME);
        return self::doSelect($c);
    }
}

Reading the error carefully it says the Method is not found - this assumes it found the Class and Peer file correctly.  That's really strange... is the message accurate or is there some other condition that might generate this error???

I've been using Propel for about 16 months - not a newbie!  Please don't ask newbie questions.

What else is different between these two machines:
Dev = MySQL 5
Prod = MySQL 4
Dev = PHP 5.1.2
Prod = PHP 5.0.4

I'm using Propel 1.2

Lastly, how do I find the Peer classes.... a little trick I picked up early on, and this code is included with every header:

function __autoload($class_name) {
    $fname = "classes/focus_caps/" . $class_name . ".php";
    if (is_readable($fname))
        require_once $fname;
    else {
        $fname = "classes/channel/" . $class_name . ".php";
        if (is_readable($fname))
            require_once $fname;
    }
}


Okay - fire the questions or point me in the right direction to fix this.

Cheers
mc



--
Murray Collingwood
Focus Computing
p +61 415 24 26 24
http://www.focus-computing.com.au
Nathan Nobbe | 2 May 2008 08:40
Picon
Gravatar

Re: Suddenly the peer methods disappeared

On Fri, May 2, 2008 at 12:21 AM, Murray Collingwood <murray <at> focus-computing.com.au> wrote:

Hello

Something awful just happened and I'm not sure what to do....

My app uses two databases, caps and capext.

I've been working on a development system (WAMP) and building my app - everything was working beautifully.

I went to publish my app to my server (LAMP) and suddenly I get this message:
Fatal error: Call to undefined method OfficerPeer::selectall() in /home/www/static/caps/setup.php on line 7
 
as a real quick sanity check to ensure the autoloader is grabbing the file w/ OfficerPeer.

if(!class_exists('OfficerPeer')) {
    die(var_dump(get_included_files()));
}
$officers = OfficerPeer::selectAll();


Lastly, how do I find the Peer classes.... a little trick I picked up early on, and this code is included with every header:

function __autoload($class_name) {
    $fname = "classes/focus_caps/" . $class_name . ".php";
    if (is_readable($fname))
        require_once $fname;
    else {
        $fname = "classes/channel/" . $class_name . ".php";
        if (is_readable($fname))
            require_once $fname;
    }
}

im guessing it has something to do w/ the autoloader above, not the code itself, but maybe where the require_once directives are looking..  have you dumped the include path on both boxes ?

-nathan
Murray Collingwood | 2 May 2008 10:09
Picon
Favicon

Re: Suddenly the peer methods disappeared

Hi Nathan

I added this code and continue to get the same error.

That is, it didn't die and spit out an error message...

This is consistent with the Propel message, indicating the method wasn't found, not that the class wasn't found.

I have checked the permissions, -rw-rw-rw across the board.   I can't see any reason why PHP might not be able to read the file.

Just did some more testing and I found the problem.  Remember how I had this autoload setup... well the OfficerPeer is in classes/channel however there was an older incorrect version hanging around in classes/focus_caps that was causing me issues.  I removed the classes from focus_caps and all is working sweetly.

function __autoload($class_name) {
    $fname = "classes/focus_caps/" . $class_name . ".php";
    if (is_readable($fname))
        require_once $fname;
    else {
        $fname = "classes/channel/" . $class_name . ".php";
        if (is_readable($fname))
            require_once $fname;
    }
}

Thanks for your suggestions, but it seems the Propel message was exactly correct.  BTW, it finally clicked when I printed the $fname of the classes being opened from the above function.  Just glad to prove that once again Propel has no bugs!

Cheers
mc


--
Murray Collingwood
Focus Computing
p +61 415 24 26 24
http://www.focus-computing.com.au
Nathan Nobbe | 2 May 2008 11:00
Picon
Gravatar

Re: Suddenly the peer methods disappeared

On Fri, May 2, 2008 at 2:09 AM, Murray Collingwood <murray <at> focus-computing.com.au> wrote:

Hi Nathan

I added this code and continue to get the same error.

That is, it didn't die and spit out an error message...

This is consistent with the Propel message, indicating the method wasn't found, not that the class wasn't found.

I have checked the permissions, -rw-rw-rw across the board.   I can't see any reason why PHP might not be able to read the file.

Just did some more testing and I found the problem.  Remember how I had this autoload setup... well the OfficerPeer is in classes/channel however there was an older incorrect version hanging around in classes/focus_caps that was causing me issues.  I removed the classes from focus_caps and all is working sweetly.


function __autoload($class_name) {
    $fname = "classes/focus_caps/" . $class_name . ".php";
    if (is_readable($fname))
        require_once $fname;
    else {
        $fname = "classes/channel/" . $class_name . ".php";
        if (is_readable($fname))
            require_once $fname;
    }
}

Thanks for your suggestions, but it seems the Propel message was exactly correct.  BTW, it finally clicked when I printed the $fname of the classes being opened from the above function.  Just glad to prove that once again Propel has no bugs!

sounds good; i actually hazed over that part about the method not being found; makes sense that the class was already loaded... just the wrong one!  glad to hear you figured it out.

-nathan

Taylor Dondich | 2 May 2008 19:35
Picon

I have multiple things that I want to use propel for, with different databases

Hi all.  I have a situation where I'm building some libraries (that
will reside in my pear directory) which uses propel to connect to
their respective databases.  Then I have client applications that
themselves has propel usage as well.  Unfortunately, the
multi-component documentation is not the best and it's not laid out in
the situation I'm trying to address.  Was wondering if anyone had any
suggestions?  I am still using 1.2, but if switching to 1.3 will
assist in this as well, I'd be more than happy to migrate at this
time.

Thanks for the info!

Taylor
Murray Collingwood | 3 May 2008 00:17
Picon
Favicon

Re: I have multiple things that I want to use propel for, with different databases

Hi Taylor

This is my 2c worth... http://www.focus-computing.com.au/Tools.do?f=detail&icid=1521

Cheers
mc


2008/5/3 Taylor Dondich <tdondich <at> gmail.com>:
Hi all.  I have a situation where I'm building some libraries (that
will reside in my pear directory) which uses propel to connect to
their respective databases.  Then I have client applications that
themselves has propel usage as well.  Unfortunately, the
multi-component documentation is not the best and it's not laid out in
the situation I'm trying to address.  Was wondering if anyone had any
suggestions?  I am still using 1.2, but if switching to 1.3 will
assist in this as well, I'd be more than happy to migrate at this
time.

Thanks for the info!

Taylor

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe <at> propel.tigris.org
For additional commands, e-mail: users-help <at> propel.tigris.org




--
Murray Collingwood
Focus Computing
p +61 415 24 26 24
http://www.focus-computing.com.au
Bálint Kriván | 6 May 2008 11:23

Re: Strange new error <at> propel-gen

I'm not getting back any answers... :(
I think the solution is very simple: We should check the local and foreign tables aswell, not just the "$map"s.

I look forward to your answers!

Regards,
Bálint Kriván

On Tue, Apr 29, 2008 at 4:57 PM, Bálint Kriván <balint <at> krivan.info> wrote:
I think, I've found out, what's the problem, I've tried to add a ticket, but rejected, here is the source:

=========================

I have the following tables:

{{{
emodell( emodell_id, user_id, ... )
ds_profile( user_id, author_name )
user( user_id, ... )
}}}

''emodell'' table is connected to ''ds_profile'' 1:1 with user_id.
''ds_profile'' table is connected to ''user'' 1:1 with user_id aswell.

It's not the issue, when emodell's foreign key is defined both directions, because the links aren't the following: emodell <-> ds_profile, but emodell -> ds_profile -> user.

As I checked the source of engine/database/model/ForeignKey.php, it's comparing the LocalForeignMapping. But, here comes the problem:
When emodell -> ds_profile, the map is the following ($map):

{{{
Array
(
    [user_id] => user_id
)
}}}

It's correct, because our foreign key is user_id.

But when we check the ds_profile -> user connection, we get this aswell for $fkMap:

{{{
Array
(
    [user_id] => user_id
)
}}}

And now he thinks (because this 2 maps are the same), that we have foreign keys both directions, but we don't!

So I'm think there is a problem with this, and it's strange.

Thanks!

p.s.: I hope my explanation was understandable, if not, let me know, I'm trying to solve this issue, because it's important for me :D

=========================


On Sat, Apr 26, 2008 at 7:09 PM, Bálint Kriván <balint <at> krivan.info> wrote:
Hi!

I've just moved to my new PC, and just configured lamp, projects, etc.
As I planned, I've installed propel in pear-way (the beta, ofc). And I was surprised, when "propel-gen forum" (forum = my project) has been failed:

=====================================

balint <at> balint-desktop:~/public_html/ds_svn/propel-projects$ propel-gen forum
Buildfile: /usr/share/php/data/propel_generator/pear-build.xml
[resolvepath] Resolved forum to /home/balint/public_html/ds_svn/propel-projects/forum

-- [snap] --

[propel-om]     + emodell
[propel-om]         -> BaseEmodellPeer [builder: PHP5PeerBuilder]
[propel-om]         -> BaseEmodell [builder: PHP5ObjectBuilder]
Execution of target "om-template" failed for the following reason: /usr/share/php/data/propel_generator/build-propel.xml:477:1: The 1:1 relationship expressed by foreign key emodell_FK_2 is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)
[phingcall] /usr/share/php/data/propel_generator/build-propel.xml:477:1: The 1:1 relationship expressed by foreign key emodell_FK_2 is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)
[phingcall] Calling Buildfile '/usr/share/php/data/propel_generator/build-propel.xml' with target 'convert-conf'
 [property] Loading /usr/share/php/data/propel_generator/./build.properties
 [property] Loading /usr/share/php/data/propel_generator/./default.properties

propel > convert-conf:

=====================================

Well, I don't get it because my definition for emodell table in the schema.xml is this:

  <table name="emodell" idMethod="native">
    <vendor type="mysql">
      <parameter name="Name" value="emodell"/>
      <parameter name="Engine" value="InnoDB"/>
      <parameter name="Version" value="10"/>
      <parameter name="Row_format" value="Compact"/>
      <parameter name="Rows" value="2"/>
      <parameter name="Avg_row_length" value="8192"/>
      <parameter name="Data_length" value="16384"/>
      <parameter name="Max_data_length" value="0"/>
      <parameter name="Index_length" value="16384"/>
      <parameter name="Data_free" value="0"/>
      <parameter name="Auto_increment" value="3"/>
      <parameter name="Create_time" value="2008-03-08 11:49:44"/>
      <parameter name="Update_time" value=""/>
      <parameter name="Check_time" value=""/>
      <parameter name="Collation" value="utf8_hungarian_ci"/>
      <parameter name="Checksum" value=""/>
      <parameter name="Create_options" value=""/>
      <parameter name="Comment" value="InnoDB free: 3072 kB; (`user_id`) REFER `forum/user`(`user_id`) ON DELETE CASCAD"/>
    </vendor>
    <column name="emodell_id" type="BIGINT" required="true" autoIncrement="true" primaryKey="true">
      <vendor type="mysql">
        <parameter name="Field" value="emodell_id"/>
        <parameter name="Type" value="bigint(20)"/>
        <parameter name="Null" value="NO"/>
        <parameter name="Key" value="PRI"/>
        <parameter name="Default" value=""/>
        <parameter name="Extra" value="auto_increment"/>
      </vendor>
    </column>
    <column name="user_id" type="BIGINT" required="true" default="">
      <vendor type="mysql">
        <parameter name="Field" value="user_id"/>
        <parameter name="Type" value="bigint(20)"/>
        <parameter name="Null" value="NO"/>
        <parameter name="Key" value="MUL"/>
        <parameter name="Default" value=""/>
        <parameter name="Extra" value=""/>
      </vendor>
    </column>

--- [snap] ---

    <foreign-key foreignTable="user" onDelete="CASCADE" onUpdate="RESTRICT">
      <reference local="user_id" foreign="user_id"/>
    </foreign-key>
    <foreign-key foreignTable="ds_profile" onDelete="RESTRICT" onUpdate="RESTRICT">
      <reference local="user_id" foreign="user_id"/>
    </foreign-key>
    <index name="user_id">
      <index-column name="user_id"/>
      <vendor type="mysql">
        <parameter name="Table" value="emodell"/>
        <parameter name="Non_unique" value="1"/>
        <parameter name="Key_name" value="user_id"/>
        <parameter name="Seq_in_index" value="1"/>
        <parameter name="Column_name" value="user_id"/>
        <parameter name="Collation" value="A"/>
        <parameter name="Cardinality" value="2"/>
        <parameter name="Sub_part" value=""/>
        <parameter name="Packed" value=""/>
        <parameter name="Null" value=""/>
        <parameter name="Index_type" value="BTREE"/>
        <parameter name="Comment" value=""/>
      </vendor>
    </index>
  </table>

And "user" table don't have any foreign keys, and "ds_profile" is connected to "user". So directly emodell is not connected to any other table 1:1 in both directions, but emodell is connected to ds_profile 1:1, and ds_profile is connected to user 1:1, but emodell is connected to user 1:1 aswell.

Maybe the problem is that $emodell->getDsProfile()->getUser() == $emodell->getUser() ?

Please help me, because I'm lost, why there is an error here, where on the other PC wasn't any.

Thanks in advance,
Kriván Bálint

p.s.: If any other infos are needed, let me know!



--
Kriván Bálint

Sven Kretschmann | 6 May 2008 16:22
Favicon

Using joins on tables with combined join clause


Hi Hans,

just to reroll the case again...

I just found some time to test the patch against the existing unit tests. The CriteriaTest package breaks in
nearly every test, as the BasePeer takes the column type into account, asking the DBMap. Latter throws an
exception as TABLE_A, etc. is not defined. In addition to that the testJoinObject throws an error, as the
constructor API has changed and no longer accepts a string as first parameter, but a Criterion object.

I'm not sure what to do next (at least in this case ;) )...

Sven

-----Ursprüngliche Nachricht-----
Von: Hans Lellelid [mailto:hans <at> velum.net] 
Gesendet: Donnerstag, 21. Februar 2008 12:12
An: users <at> propel.tigris.org
Betreff: Re: AW: [propel] Using joins on tables with combined join clause

Hi Sven,

This patch looks good to me (though I have not applied it to my working copy).  It definitely is a big change,
but as long as it doesn't break any existing Criteria usage (or unit tests), I'm fine with this being
applied.  I think supporting more complex joins is a great feature.

Hans

Sven Kretschmann wrote:
>  
> Hi Hans,
>
> I wrote the patch from scratch, following another concept to handle joins as the existing code.
>
> Joins do hold a criterion object containing all clauses needed. The old API is still supported, so there is
no need to refactor existing code.
>
> I would have liked to answer to the ticket mentioned in your previous 
> answer, as it tells just the problem I had, but for spam prevention 
> reasons I was neither able to answer nor attach the patch file. I 
> would appreciate you to give me a trac account for preventing this ;)
>
> The usage of the joins after patching is like the following example shows:
>
> $criteria = new Criteria();
> $criterion = $criteria->getJoinCriterion(MyPeer::COLUMN, 
> MyReferencePeer::FOREIGN_COLUM, Criteria::EQUAL); 
> $criterion->addAnd($criteria->getNewCriterion(MyReferencePeer::ANOTHER
> _COLUMN, $value, Criteria::EQUAL));
>             
> $criteria->addJoin($criterion, Criteria::LEFT_JOIN);
>
> The difference between join criterions and normal criterions is the way the right column or the value
respectively are put into the query. The join criterions do put the value plain as is into the query,
whereas the normal criterions handle it the way  the way they used to.
>
> I will be testing this patch over the next time, as it is a bit more complex there may still be some traps to
fall into.
>
> Regards
>
> Sven
>  
> Sven Kretschmann
> IT Developer
>
> E-Mail: sven.kretschmann <at> exozet.com
> URL: http://www.exozet.com/
> Tel.: +49 (30) 24 65 60 - 0
> Fax:  +49 (30) 24 65 60 - 29
>
> Exozet Berlin GmbH
> Oberbaum City
> Rotherstr. 20
> 10245 Berlin
>
> Geschäftsführer: Frank Alexander Zahn
> Handelsregisternummer: HRB 58797 Amtsgericht Charlottenburg
>
> --- NEWS --------------------------------------------------------
>
> exozet interaktiviert die ZDF Mediathek
>  
> exozet interact hat die ZDF Mediathek mit einer neuen Video-On-Demand-Anwendung ausgestattet und die
beliebte Plattform damit um neue Rückkanalfunktionen erweitert. Der auf Basis der preisgekrönten
IPTV-Komplettlösung TVNEXT entwickelte Video-Player ermöglicht den Nutzern der Mediathek,
einzelne Videobeiträge zu kommentieren und zu bewerten. Für die Online-Redaktion des ZDF schafft die
Anwendung ein hohes Maß an Flexibilität in der Präsentation interaktiver Bewegtbildinhalte.
>
> http://www.zdf.de/ZDFmediathek
> http://www.exozet.com/tvnext
> -----Ursprüngliche Nachricht-----
> Von: Hans Lellelid [mailto:hans <at> velum.net]
> Gesendet: Mittwoch, 20. Februar 2008 02:32
> An: users <at> propel.tigris.org
> Betreff: Re: [propel] Using joins on tables with combined join clause
>
> Hi Sven,
>
> Sven Kretschmann wrote:
>   
>>  
>> Hi there,
>>
>> I have to develop an application using reference tables with a combined join clause of source id and
fieldname. As the referenced entries may be empty I'll use a left join, but this is nonrelevant for this case.
>> When using the normal Criteria::adJoin method I can only give one column per table, instead of giving
both keys I'd like to use or better give a criterion containing all clauses to use for the join.
>>
>> The query I'd like to build looks like this:
>>
>> SELECT my_table.ID FROM my_table LEFT JOIN my_reference_table ON 
>> my_reference_table.source_id = my_table.id AND 
>> my_reference_table.fieldname = 'reference_field';
>>
>> I do not want to use the workaround $criteria->add('my_reference_table.fieldname',
"IFNULL(my_reference_table.fieldname, 'reference_field') = 'reference_field'",
Criteria::CUSTOM); for performance reasons.
>>   
>>     
>
> Does this ticket look like it would address your need?  
> http://propel.phpdb.org/trac/ticket/167
>
> While there's not a guarantee that we'll get this added for initial 1.3, I would like to see this supported. 
The patch is not up-to-date with the way we're building the SELECT SQL, though, so there's some work needed
there.  If you want to help implement this, it would be very welcome.
>
> Cheers,
> Hans
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> propel.tigris.org
> For additional commands, e-mail: users-help <at> propel.tigris.org
>
>   
> ----------------------------------------------------------------------
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> propel.tigris.org
> For additional commands, e-mail: users-help <at> propel.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe <at> propel.tigris.org
For additional commands, e-mail: users-help <at> propel.tigris.org
Gatoelho | 7 May 2008 21:40
Picon

Database normalization and composite PK


The following schema

client:
  id: {type: integer, primaryKey:true }

users:
  user_id: {type: integer, primaryKey:true, foreignTable: client,
foreignReference: id}
  id: {type: integer}

profiles:
  client_id: {type: integer, primaryKey:true, foreignTable: client,
foreignReference: id}
  id: {type: integer}

userprofile:
  client_id: {type: integer, primaryKey:true}
  user_id: {type: integer, primaryKey:true}
  profile_id: {type: integer, primaryKey:true}
  _foreignKeys:
    fk_user:
      foreignTable: users

      references:
        - { local: client_id, foreign: client_id }
        - { local: user_id, foreign: id }
    fk_profile:
      foreignTable: profile

      references:
        - { local: client_id, foreign: client_id }
        - { local: profile_id, foreign: id }

How to model it in Propel? Im using it Symfony and it isn't really working,
I'm wondering if propel is compatible with it. Anyway, 
http://www.symfony-project.org/forum/index.php/m/51438/ you can read the
whole discussion here 
--

-- 
View this message in context: http://www.nabble.com/Database-normalization-and-composite-PK-tp17112420p17112420.html
Sent from the propel - users mailing list archive at Nabble.com.
Ron Rademaker | 8 May 2008 09:16
Picon

Re: Database normalization and composite PK

Hi,

What does 'isn't really working' mean? (Is it laying on the couch all 
day watching tv? ;) ).

Anyway, I just fixed some things in the propel 1.3 branch in regard to 
multicolumn foreign keys and the generated Join functions in the Peer 
classes. Maybe that'll fix your problems.

Ron

Gatoelho wrote:
> The following schema
>
> client:
>   id: {type: integer, primaryKey:true }
>
> users:
>   user_id: {type: integer, primaryKey:true, foreignTable: client,
> foreignReference: id}
>   id: {type: integer}
>
> profiles:
>   client_id: {type: integer, primaryKey:true, foreignTable: client,
> foreignReference: id}
>   id: {type: integer}
>
> userprofile:
>   client_id: {type: integer, primaryKey:true}
>   user_id: {type: integer, primaryKey:true}
>   profile_id: {type: integer, primaryKey:true}
>   _foreignKeys:
>     fk_user:
>       foreignTable: users
>
>       references:
>         - { local: client_id, foreign: client_id }
>         - { local: user_id, foreign: id }
>     fk_profile:
>       foreignTable: profile
>
>       references:
>         - { local: client_id, foreign: client_id }
>         - { local: profile_id, foreign: id }
>
> How to model it in Propel? Im using it Symfony and it isn't really working,
> I'm wondering if propel is compatible with it. Anyway, 
> http://www.symfony-project.org/forum/index.php/m/51438/ you can read the
> whole discussion here 
>   

Gmane