Skip to main content

Create Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write''core_read'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns(array('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)')) )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr(" ( $select ) ")), 'main_table.user_id = art.artist_id', array() ); 

Create Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 

Create Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_read'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns(array('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)')) )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr(" ( $select ) ")), 'main_table.user_id = art.artist_id', array() ); 
deleted 5 characters in body
Source Link
Amit Bera
  • 77.8k
  • 21
  • 127
  • 240

Create Zend Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 

Create Zend Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 

Create Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 
added 62 characters in body
Source Link
Amit Bera
  • 77.8k
  • 21
  • 127
  • 240

Create Zend Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 

Create Zend Virtual Query

Create ZEND SQL query which is give you artworks_uploaded basic of artist_id,which give an virtual result query with count and artist id.

$ReadAdapter=Mage::getSingleton('core/resource')->getConnection('core_write'); $select = $ReadAdapter()->select() ->from('mage_art_works', array()) ->columns('artist_id', 'artworks_uploaded' => new Zend_Db_Expr('COUNT(*)') )->group('mage_art_works.artist_id'); 

Alias table using above result:

then add the below ZEND SQL to the alias table

$collection->getSelect() ->joinLeft( array('art' => new Zend_Db_Expr($select)), 'main_table.user_id = art.artist_id', array() ); 
Mistake... it should be $select from $ReadAdapter
Source Link
Amit Bera
  • 77.8k
  • 21
  • 127
  • 240
Loading
Source Link
Amit Bera
  • 77.8k
  • 21
  • 127
  • 240
Loading