AshishJoshi-asj / zfdatagrid

Automatically exported from code.google.com/p/zfdatagrid
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Undefined index: table and tableAlias #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Working on a select with joins

What is the expected output? What do you see instead?
Grid is well displayed, but two notices appears just after the grid :
Notice: Undefined index: table in
/home/m.thomas/www/stamp/trunk/libs/Bvb/Grid/Data.php on line 370
Call Stack
10  0.2196  12205364    Bvb_Grid_Data->query( ) ../Grid.php:154
11  0.2222  12393408    Bvb_Grid_Data->setSource( )

Notice: Undefined index: tableAlias in
/home/m.thomas/www/stamp/trunk/libs/Bvb/Grid/Data.php on line 371
Call Stack
#   Time    Memory  Function    Location
10  0.2196  12205364    Bvb_Grid_Data->query( ) ../Grid.php:154
11  0.2222  12393408    Bvb_Grid_Data->setSource( )

What version of the product are you using? On what operating system?
v6.alpha, under Linux Fedora

Please provide any additional information below.

Original issue reported on code.google.com by tribal...@gmail.com on 22 Feb 2010 at 2:59

GoogleCodeExporter commented 9 years ago
Hi,

Can you please post your grid code? or email it to geral[that 
thing]petala-azul.com

Best Regards,
Bento Vilas Boas

Original comment by pao.fre...@gmail.com on 22 Feb 2010 at 3:46

GoogleCodeExporter commented 9 years ago
Hi,

Looking at getMainTable() method in Bvb_Grid_Source_Zend_Select class, we can 
see
that 'table' index is created only for Zend_Db_Select objects which have a 
'from'
joinType and not for others (eg. 'inner join' joinType).

My query is $this->_getDb()->select()->from('XXX');

in getMainTable() method:
- echo $this->_select echoes : SELECT `XXX`.* FROM `XXX`
- AND with Zend_debug::dump($from) I get a 'inner join' joinType :

array
  'import_4' => 
    array
      'joinType' => string 'inner join' (length=10)
      'schema' => null
      'tableName' => string 'import_4' (length=8)
      'joinCondition' => null

So, in this case no table can be found.

Removing the joinType condition in the foreach of the method solves the problem 
(and
also the issue 174)

Original comment by tribal...@gmail.com on 22 Feb 2010 at 4:12

GoogleCodeExporter commented 9 years ago
Hi,

This table is used for CRUD operations. So I need to get the 'main' table for 
then
insert data there.

The odd thing is that this query

$this->_db->select()->from('Country')

outputs this:

Array
(
    [Country] => Array
        (
            [joinType] => from
            [schema] => 
            [tableName] => Country
            [joinCondition] => 
        )

)

Which version of ZF are you using?

Best Regards,
Bento Vilas Boas

Original comment by pao.fre...@gmail.com on 22 Feb 2010 at 4:27

GoogleCodeExporter commented 9 years ago
And the raw SQL is 

SELECT `Country`.* FROM `Country`

Best Regards,
Bento Vilas Boas

Original comment by pao.fre...@gmail.com on 22 Feb 2010 at 4:28

GoogleCodeExporter commented 9 years ago
I'm using 1.9.2 version.

But, in general, even if that works with your query, that could not work with a 
query
which has joined tables, is not it ?
If it is the case, the good way would be to keep on searching a 'join' joinType 
in
the foreach, and if none was found and tables are not empty so taking the first 
table.

I say "first table" to simplify, the best way would be to give possibility to
developers to specify the table they want to be the main (eg. with a join 
relation,
for a grid you could want to use table as main, for crud or detail for example, 
and
in another grid with the same relation you could want to specify an other table 
(for
crud, details, ...)), knowing that with joins the primary key of a table is not
neccessary "unique" in query's result

Original comment by tribal...@gmail.com on 22 Feb 2010 at 4:50

GoogleCodeExporter commented 9 years ago
Hi,

You are right.

I've made some changes.

If $from has only one element, that's the table that will be used.
If $from has the 'joinType'=>from,  that's the table that will be used.

else if will be the first element.

But I will provide a new method to specify the table for CRUD operations,

Check the revision 640
thanks,

Best Regards,
Bento Vilas Boas

Original comment by pao.fre...@gmail.com on 22 Feb 2010 at 5:18

GoogleCodeExporter commented 9 years ago
That works, thanks !

Original comment by tribal...@gmail.com on 22 Feb 2010 at 5:44

GoogleCodeExporter commented 9 years ago

Original comment by bento.vi...@gmail.com on 3 Mar 2010 at 4:56