#016208: Warning in ezcQuery alias function

Description:

Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in ezcomponents/Database/src/sqlabstraction/query.php on line 232

Warning shows up then generating query like this :
SELECT
`lh_gallery_images`.`pid`,
`lh_gallery_images`.`aid`,
`lh_gallery_images`.`filepath`,
`lh_gallery_images`.`filename`,
`lh_gallery_images`.`filesize`,
`lh_gallery_images`.`total_filesize`,
`lh_gallery_images`.`pwidth`,
`lh_gallery_images`.`pheight`,
`lh_gallery_images`.`hits`,
`lh_gallery_images`.`ctime`,
`lh_gallery_images`.`owner_id`,
`lh_gallery_images`.`pic_rating`,
`lh_gallery_images`.`votes`,
`lh_gallery_images`.`title`,
`lh_gallery_images`.`caption`,
`lh_gallery_images`.`keywords`,
`lh_gallery_images`.`pic_raw_ip`,
`lh_gallery_images`.`approved`,
`lh_gallery_images`.`mtime`,
`lh_gallery_images`.`comtime`,
`lh_gallery_images`.`sort_rated` FROM `lh_gallery_images`
INNER JOIN ( SELECT pid FROM lh_gallery_images ORDER BY comtime DESC, pid DESC LIMIT 20 OFFSET 20 ) AS items
ON lh_gallery_images.pid = items.pid


Environment:

Operating System:
PHP Version: (5.3.1)
Database and version: 5.1 mysql
Browser (and version):


Steps to Reproduce:

CREATE TABLE IF NOT EXISTS `lh_gallery_images` (
  `pid` int(11) NOT NULL AUTO_INCREMENT,
  `aid` int(11) NOT NULL DEFAULT '0',
  `filepath` varchar(255) NOT NULL DEFAULT '',
  `filename` varchar(255) NOT NULL DEFAULT '',
  `filesize` int(11) NOT NULL DEFAULT '0',
  `total_filesize` int(11) NOT NULL DEFAULT '0',
  `pwidth` smallint(6) NOT NULL DEFAULT '0',
  `pheight` smallint(6) NOT NULL DEFAULT '0',
  `hits` int(10) NOT NULL DEFAULT '0',
  `ctime` int(11) NOT NULL DEFAULT '0',
  `owner_id` int(11) NOT NULL DEFAULT '0',
  `pic_rating` int(11) NOT NULL DEFAULT '0',
  `votes` int(11) NOT NULL DEFAULT '0',
  `title` varchar(255) NOT NULL DEFAULT '',
  `caption` text NOT NULL,
  `keywords` varchar(255) NOT NULL DEFAULT '',
  `pic_raw_ip` tinytext,
  `approved` int(11) NOT NULL DEFAULT '0',
  `mtime` int(11) NOT NULL,
  `comtime` int(11) NOT NULL,
  `sort_rated` text NOT NULL,
  PRIMARY KEY (`pid`),
  KEY `owner_id` (`owner_id`),
  KEY `pic_hits` (`hits`),
  KEY `pic_rate` (`pic_rating`),
  KEY `pic_aid` (`aid`),
  KEY `mtime` (`mtime`),
  KEY `comtime` (`comtime`,`pid`),
  KEY `pid_4` (`hits`,`pid`),
  KEY `pid_5` (`pic_rating`,`votes`,`pid`),
  KEY `pid` (`mtime`,`pid`),
  KEY `pid_3` (`ctime`),
  KEY `pid_2` (`ctime`,`pid`),
  KEY `pid_6` (`aid`,`pid`),
  KEY `pid_7` (`aid`,`hits`,`pid`),
  KEY `pid_8` (`aid`,`mtime`,`pid`),
  KEY `pid_9` (`aid`,`pic_rating`,`votes`,`pid`),
  KEY `pid_10` (`aid`,`comtime`,`pid`)
) ENGINE=MyISAM;

INSERT INTO `lh_gallery_images` (`pid`, `aid`, `filepath`, `filename`, `filesize`, `total_filesize`, `pwidth`, `pheight`, `hits`, `mtime`, `ctime`, `owner_id`, `pic_rating`, `votes`, `title`, `caption`, `keywords`, `pic_raw_ip`, `approved`, `comtime`, `sort_rated`) VALUES
(371, 3, 'Anime_wallpapers/800-x-600/', 'Love_Hina_Wallpaper_New_Style.jpg', 174307, 212135, 800, 600, 85, 1265736996, 1166289154, 1, 0, 0, '', '', '', '', 1, 0, ''),
(370, 3, 'Anime_wallpapers/800-x-600/', 'lovehina03.jpg', 106984, 145119, 800, 600, 112, 1264385172, 1166289153, 1, 0, 0, '', '', '', '', 1, 0, ''),
(369, 3, 'Anime_wallpapers/800-x-600/', 'Legendary_Pilot.jpg', 125105, 161098, 800, 600, 93, 1264490211, 1166289153, 1, 0, 0, '', '', '', '', 1, 0, ''),
(368, 3, 'Anime_wallpapers/800-x-600/', 'Lamu_0005_800.jpg', 79291, 114795, 800, 600, 82, 1264384917, 1166289153, 1, 0, 0, '', '', '', '', 1, 0, ''),
(367, 3, 'Anime_wallpapers/800-x-600/', 'kof_020.jpg', 106859, 140102, 800, 600, 74, 1266237009, 1166289152, 1, 0, 0, '', '', '', '', 1, 0, ''),
(366, 3, 'Anime_wallpapers/800-x-600/', 'LamÅ?1.gif', 144288, 173386, 800, 600, 76, 1266079019, 1166289152, 1, 0, 0, '', '', '', '', 1, 0, ''),
(365, 3, 'Anime_wallpapers/800-x-600/', 'kenshin15.jpg', 80618, 110826, 800, 600, 76, 1264610871, 1166289152, 1, 0, 0, '', '', '', '', 1, 0, ''),
(364, 3, 'Anime_wallpapers/800-x-600/', 'KenShiro00.jpg', 140451, 171713, 800, 600, 72, 1266173264, 1166289152, 1, 0, 0, '', '', '', '', 1, 0, ''),
(363, 3, 'Anime_wallpapers/800-x-600/', 'Kawaii_Girl.jpg', 420355, 451310, 800, 600, 78, 1266182158, 1166289151, 1, 0, 0, '', '', '', '', 1, 0, ''),
(362, 3, 'Anime_wallpapers/800-x-600/', 'Karu_the_teacher.jpg', 70855, 101303, 800, 600, 81, 1264385167, 1166289151, 1, 0, 0, '', '', '', '', 1, 0, '');

eZ Components syntax:

$session = erLhcoreClassGallery::getSession();
$q2 = $q->subSelect();
$q2->select( 'pid' )->from( 'lh_gallery_images' );
$q = $session->createFindQuery( 'erLhcoreClassModelGalleryImage' );  
$q2->limit(20,0);
          $q2->orderBy('pid DESC');
          $q->innerJoin( $q->alias( $q2, 'items' ), 'lh_gallery_images.pid', 'items.pid' );   

I think issue is in $q->alias( $q2, 'items' ) statement. Witch is eZ Components valid, only perhaps to fancy. Not sure that i should consider this as eZ Components bug or as programming logical bug, like there is no other issues running this query.

- Attachments

No attachments for this issue.


- Comments

Fixed in revision #11394. Thanks for the bug report.

#264767 by Kore Nordmann on February 18th, 2010 [Permanent Link]

- History
Properties
Type Bug
Priority Medium
Component Components » Database
Affects Unknown
Fix Version -
Reporter Remigijus Kiminas
Responsible Kore Nordmann
Status 0 Closed
Resolution Fixed
Created February 17th, 2010
Updated February 18th, 2010
Resolved February 18th, 2010
 
Navigation [Permanent Link]
Previous Issue
Back to Issues List
Next Issue: #015537
  Graph shows to small and truncated rotated axis labels