Problem DataGrind_Bind

thread: 23 messages  |  last: a year ago  |  started: wednesday, march 31, 2010, 6:04 am pdt


#1  |  Mattia Bagiella (Switzerland) Switzerland
Wednesday, March 31, 2010, 6:04 AM PDT

Hello all,

I have some problem with my DataG_bind, i would be very thankfull if you try to figure out my problems :D
 
protected function dtgTales_Bind() {            
    $this->dtgTales->TotalItemCount = Tales::CountAll();  
    $objClauses = array();
    $objMembre=unserialize($_SESSION['Member'])
    $objConditions = QQ::AndCondition(
                       QQ::Equal(QQN::Tales()->Visible, 0),
                       QQ::AndCondition(
                           QQ::NotEqual(SuppressTales()->TalesId, QQN::Tales()->Id)
                           QQ::NotEqual(SuppressTales()->MemberId,$objMember->Id);

    $this->dtgConte->DataSource = Tales::QueryArray($objConditions,$objClauses);
}

For more details here my table
Member
id PK
name

Tales
id PK
name
member_id FK

SuppressTales
id PK
member_id FK
tales_id FK

I would like to have on my dtgTales only the tales not suppress by the member logged

I tried many things but I dont find the solution, thx for help and apologize for my mistakes

#2  |  Gaspar Attila (Odorheiu Secuiesc, RO) Romania
Wednesday, March 31, 2010, 8:54 AM PDT

Hello mbagiella,

First, if count all Tales then your paginator not render the correct page numbers. Use QueryCount and for condition use the same as used in QueryArray.
Then, in $objMembre=unserialize($_SESSION['Member']), I think $objMembre is a typo and you want it $objMember.
In conditions always use nodes.

For ex.:
  Bad: QQ::NotEqual(SuppressTales()->TalesId, QQN::Tales()->Id)
  Good(I think because not sure you use unique fields or not): QQ::NotEqual(QQN::Tales()->...->TalesId, QQN::Tales()->Id) where ... is a reverse reference.
More info here: http://examples.qcodo.com/examples/code_generator/relationships.php

In $this->dtgConte->DataSource ... your query result attached to dtgConte and not dtgTales.

Footnote:
  Not sure but I think you need to use a QQ::Expand or QQ::ExpandAsArray for that query.

For more information check this:
  http://examples.qcodo.com/examples/more_codegen/early_bind.php
and
  http://examples.qcodo.com/examples/qcodo_query/reverse.php

 


Sorry for my bad english...

Regards,
  Attila

#3  |  Mattia Bagiella (Switzerland) Switzerland
Wednesday, March 31, 2010, 9:20 AM PDT

Thank you, but I still not manage to make the datagrid, when i try with my table SuppressTales

Cannot use QQNode for “SuppressTales” when querying against the “Tales” table

The only unique key are the ID :(

#4  |  Gaspar Attila (Odorheiu Secuiesc, RO) Romania
Wednesday, March 31, 2010, 3:02 PM PDT

Try this:

   $objCondition = QQ::NotEqual(QQN::Tales()->SuppressTales->MemberId,$objMember->Id);

  $this->dtgTales->TotalItemCount = Tales::QueryCount( $objCondition );
  $this->dtgTales->DataSource = Tales::QueryArray( $objCondition );



#5  |  Mattia Bagiella (Switzerland) Switzerland
Thursday, April 1, 2010, 1:32 AM PDT

I tried your method and I still have this problem

Undefined GET property or variable in 'QQNodeTales' class: SuppressTales

$objConditions = QQ::AndCondition(
 QQ::Equal(QQN::Tales()->Visible, 0),
 QQ::NotEqual(QQN::Tales()->SuppressTales->MemberId,$this->objMember->Id)
);


I Would like a Condition like that

$objConditions = QQ::AndCondition(
               QQ::Equal(QQN::SuppressTales()->MembreId, $this->objMembre->Id),
               QQ::Equal(QQN::SuppressTales()->TaleseId, $objTales->Id)
       );
       $suppressionQuerySingle = Suppression::QuerySingle($objConditions);
             
       if($suppressionQuerySingle) dont display the tale on dtgTales;

#6  |  Gaspar Attila (Odorheiu Secuiesc, RO) Romania
Thursday, April 1, 2010, 6:52 AM PDT

What is the type of database you use?

In InnoDB define all (if not defined) relationships
or if you use MyISAM create a relationship script (more info: http://examples.qcodo.com/examples/code_generator/script_path.php) then run codegen again.

After that try again.

SuppressTales is a reference and only exist if relationships defined before generate classes from tables.

#7  |  Mattia Bagiella (Switzerland) Switzerland
Friday, April 2, 2010, 12:46 AM PDT

Here the table

CREATE TABLE IF NOT EXISTS `SupressTales` (
 `ID` varchar(200) character set utf8 collate utf8_unicode_ci NOT NULL,
 `MEMBRE_ID` int(11) NOT NULL,
 `TALES_ID` int(11) default NOT NULL,
 PRIMARY KEY  (`ID`),
 KEY `FK_SUPPRESS_MEMBRE` (`MEMBRE_ID`),
 KEY `FK_SUPPRESS_TALES` (`TALES_ID`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `SupressTales`
 ADD CONSTRAINT `SUPPRESS_ibfk_1` FOREIGN KEY (`MEMBRE_ID`) REFERENCES `membre` (`ID`),
 ADD CONSTRAINT `SUPPRESS_ibfk_2` FOREIGN KEY (`TALES_ID`) REFERENCES `tales` (`ID`) ON DELETE CASCADE;

#8  |  Vass Arpad (Szentegyháza, RO) Romania Qcodo Core Contributor
Friday, April 2, 2010, 4:14 AM PDT

Hello mbagiella,

the problem I see, is a typo, your CREATE TABLE IF NOT EXISTS `SupressTales`

is with one 'p' and you use in QQCondition a QQNode 'SuppressTales'

hope this helps your situation :)

if not, we will see further.

kind regards,

Arpi.

#9  |  Vass Arpad (Szentegyháza, RO) Romania Qcodo Core Contributor
Friday, April 2, 2010, 4:32 AM PDT

hi again,

what a rush... sorry for the incomplette answer,

you have 2 choices:
1, rename the tablename, and re-codegen, or...

2. you have to use Suppress with one “p”, this could be annoying, because all the generated methods regarding the back-reference relations with this object will generated with SupressTales.

Arpi.

#10  |  Mattia Bagiella (Switzerland) Switzerland
Friday, April 2, 2010, 12:04 PM PDT

No it's not the problem :(
Still not getting why it's not working
I tried the both side with the list of tales and the list of suppressTales :(



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.