title: CakePHP skipping over field in select * statement
body: <p>First of all, I just want to say that I understand not using CakePHP's built in functionality to find data can result in vulnerabilities. However, there is absolutely no input going into this query that the user can select. It's pre-determined and configured so there is nothing to inject. Also, I'm doing a union select which I haven't found an easy solution for this situation.</p>
  
  <p>I have the following tables (exported from PHPmyadmin)</p>
  
  <pre><code> CREATE TABLE `orders` (
    `id` int(10) NOT NULL auto_increment,
    `userid` int(10) default NULL,
    `order_status` varchar(12) NOT NULL default 'Not Filled',
    `email` varchar(50) NOT NULL,
    `total` varchar(50) NOT NULL,
    `fullName` varchar(60) NOT NULL,
    `address` varchar(50) NOT NULL,
    `city` varchar(50) NOT NULL,
    `state` varchar(50) NOT NULL,
    `zip` varchar(15) NOT NULL,
    `created` datetime default NULL,
    `modified` datetime default NULL,
    PRIMARY KEY  (`id`)
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
  
  
   CREATE TABLE `order_items` (
    `id` int(20) NOT NULL auto_increment,
    `orderid` int(10) default NULL,
    `userid` int(10) default NULL,
    `item_number` varchar(200) default NULL,
    `itemName` varchar(200) NOT NULL,
    `price` varchar(10) default NULL,
    `quantity` int(10) default NULL,
    `total` varchar(10) default NULL,
    `item_status` varchar(20) NOT NULL,
    `created` datetime default NULL,
    `modified` datetime default NULL,
    PRIMARY KEY  (`id`),
    KEY `orderid` (`orderid`)
  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
  </code></pre>
  
  <p>Since have different number of fields I cannot do select * with union select for both tables. Here is my query (using $this->model->query())</p>
  
  <pre><code>select  orders.id, orders.userid, orders.order_status, orders.email, orders.total, orders.fullName, orders.Address, orders.city, orders.state, orders.zip, orders.created from orders where userid = '$id' and order_status = 'filled'
  UNION
  select * from order_items where userid = '$id' and item_status = 'filled'"
  </code></pre>
  
  <p>This results in order_items.orderid not being selected so I tried to select the fields individually</p>
  
  <pre><code>select  orders.id, orders.userid, orders.order_status, orders.email, orders.total, orders.fullName, orders.Address, orders.city, orders.state, orders.zip, orders.created from orders where userid = '$id' and order_status = 'filled'
  UNION
  select order_items.id, order_items.orderid, order_items.userid, order_items.item_number, order_items.itemName, order_items.price, order_items.quantity, order_items.total, order_items.item_status, order_items.created, order_items.modified where userid = '$id' and item_status = 'filled'"
  </code></pre>
  
  <p>Everything in the <strong>except</strong> for order_items.orderid was selected. When I run the query in PHPmyadmin it selects order_items.orderid so I'm almost positive it's something with CakePHP.</p>
  
  <p>I even tried changing orderid to order_id and it still skipped it</p>