473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Doctrine with SQL View

chathura86
227 100+
Hi,

here is the Docrrin class i have generated for the following SQL View

Expand|Select|Wrap|Line Numbers
  1. CREATE VIEW `STREAMLINE`.`ViewPurchaseOrderProgress` AS
  2. (SELECT
  3.     P.StockPurchaseOrderId, P.Item, I.Name, P.Ordered, IFNULL(0, G.Received) AS Received,
  4.     (P.Ordered - IFNULL(0, G.Received) + IFNULL(0, R.Returned)) AS Pending
  5. FROM
  6.     ViewStockPurchaseOrderSummary P
  7. LEFT JOIN
  8.     StockItem I
  9. ON (I.StockItemId = P.Item)
  10. LEFT JOIN
  11.     ViewStockGrnSummary G
  12. ON (G.PurchaseOrder = P.StockPurchaseOrderId AND G.Item = P.Item)
  13. LEFT JOIN
  14.     ViewStockDamageReturnSummary R
  15. ON (R.PurchaseOrder = P.StockPurchaseOrderId AND R.Item = P.Item))
  16.  
Expand|Select|Wrap|Line Numbers
  1. abstract class BaseViewPurchaseOrderProgress extends Doctrine_Record
  2. {
  3.     public function setTableDefinition()
  4.     {
  5.         $this->setTableName('ViewPurchaseOrderProgress');
  6.         $this->hasColumn('StockPurchaseOrderId', 'integer', 4, array(
  7.              'type' => 'integer',
  8.              'length' => 4,
  9.              'fixed' => false,
  10.              'unsigned' => false,
  11.              'primary' => false,
  12.              'default' => '0',
  13.              'notnull' => true,
  14.              'autoincrement' => false,
  15.              ));
  16.         $this->hasColumn('Item', 'integer', 4, array(
  17.              'type' => 'integer',
  18.              'length' => 4,
  19.              'fixed' => false,
  20.              'unsigned' => false,
  21.              'primary' => false,
  22.              'notnull' => true,
  23.              'autoincrement' => false,
  24.              ));
  25.         $this->hasColumn('Name', 'string', 128, array(
  26.              'type' => 'string',
  27.              'length' => 128,
  28.              'fixed' => false,
  29.              'unsigned' => false,
  30.              'primary' => false,
  31.              'notnull' => false,
  32.              'autoincrement' => false,
  33.              ));
  34.         $this->hasColumn('Ordered', 'decimal', 32, array(
  35.              'type' => 'decimal',
  36.              'length' => 32,
  37.              'fixed' => false,
  38.              'unsigned' => false,
  39.              'primary' => false,
  40.              'notnull' => false,
  41.              'autoincrement' => false,
  42.              ));
  43.         $this->hasColumn('Received', 'decimal', 32, array(
  44.              'type' => 'decimal',
  45.              'length' => 32,
  46.              'fixed' => false,
  47.              'unsigned' => false,
  48.              'primary' => false,
  49.              'notnull' => false,
  50.              'autoincrement' => false,
  51.              ));
  52.         $this->hasColumn('Pending', 'decimal', 34, array(
  53.              'type' => 'decimal',
  54.              'length' => 34,
  55.              'fixed' => false,
  56.              'unsigned' => false,
  57.              'primary' => false,
  58.              'notnull' => false,
  59.              'autoincrement' => false,
  60.              ));
  61.     }
  62.  
  63.     public function setUp()
  64.     {
  65.         parent::setUp();
  66.  
  67.     }
  68. }
  69.  
I used the folllowing code to get the data

Expand|Select|Wrap|Line Numbers
  1. $poItems = Doctrine_Query::create()
  2.                         ->select('Item, Name, Ordered, Received, Pending')
  3.                         ->from('ViewPurchaseOrderProgress')
  4.                         ->where('StockPurchaseOrderId = ?', 1)
  5.                         ->fetchArray();
  6.  
but this triggers the following error

Column not found: 1054 Unknown column 'v.id' in 'field list'

and it is true that this table does not have any column with the name id

please help me to solve this as im new to doctrine

Regards
Chathura Bamunusinghe
Jan 6 '10 #1
1 3829
dlite922
1,584 Expert 1GB
Take a look at the "Doctrine_Record" class, I'm sure that has "id" in it.

I don't know what Doctrine is, but if it's a framework then I think some frameworks require all their tables to have a field called id.



Dan
Jan 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: js | last post by:
I am trying to create a primary key constraint on a view in the following statement. However, I got an error ORA-00907: missing right parenthesis. If the CONSTRAINT clause is removed, then the...
3
by: M. Mehta | last post by:
It seems that you can not create a materialized view if you are using outer joins...can someone please verify this? Thanks M. Mehta Please follow my example below: created 2 tables:
4
by: Ryan | last post by:
Bit of an obscure one here, so please bear with me. I have two copies of a database which should be identical. Both have a complex view which is identical. I can open the views and the data is as...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
4
by: Neil | last post by:
I just resolved a strange situation I was having with an ODBC linked SQL 7 view in an Access 2000 MDB file, and I'm trying to get some understanding as to what happened. The linked view was...
12
by: Neil | last post by:
I previously posted re. this, but thought I'd try again with a summary of facts. I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that is linked to the database via ODBC...
10
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
1
by: Nogusta123 | last post by:
Hi, I have had a lot of problems getting web pages, master pages and content pages to render in VS2005 design view the same as they would in Internet Explorer. I did a lot of looking on the...
6
by: Neil | last post by:
I had a strange situation with a view in SQL 7, that I could use some input on. I had a very simple view -- select a, b, c from table1 where x=y and z=q. Field a in table1 originally was varchar...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.