Search Results

Search found 40 results on 2 pages for 'dql'.

Page 1/2 | 1 2  | Next Page >

  • subquery in join with doctrine dql

    - by Martijn de Munnik
    I want to use DQL to create a query which looks like this in SQL: select e.* from e inner join ( select uuid, max(locale) as locale from e where locale = 'nl_NL' or locale = 'nl' group by uuid ) as e_ on e.uuid = e_.uuid and e.locale = e_.locale I tried to use QueryBuilder to generate the query and subquery. I think they do the right thing by them selves but I can't combine them in the join statement. Does anybody now if this is possible with DQL? I can't use native SQL because I want to return real objects and I don't know for which object this query is run (I only know the base class which have the uuid and locale property). $subQueryBuilder = $this->_em->createQueryBuilder(); $subQueryBuilder ->addSelect('e.uuid, max(e.locale) as locale') ->from($this->_entityName, 'e') ->where($subQueryBuilder->expr()->in('e.locale', $localeCriteria)) ->groupBy('e.uuid'); $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder ->addSelect('e') ->from($this->_entityName, 'e') ->join('('.$subQueryBuilder.') as', 'e_')->join ->where('e.uuid = e_.uuid') ->andWhere('e.locale = e_.locale');

    Read the article

  • Exclude rows with Doctrine ORM DQL (NOT IN)

    - by Sheriffen
    I'm building a chat application with codeigniter and doctrine. Tables: - User - User_roles - User_available Relations: ONE user have MANY roles. ONE user_available have ONE user. Users available for chatting will be in the user_available table. Problem: I need to get all users in in user_available that hasn't got role_id 7. So I need to express in DQL something like (this is not even SQL, just in words): SELECT * from user_available WHERE NOT user_available.User.Role.role_id = 7 Really stuck on this one EDIT: Guess I was unclear. The tables are already mapped and Doctrine does the INNER JOIN job for me. I'm using this code to get the admin that waited the longest but now I need the user: $admin = Doctrine_Query::create() ->select('c.id') ->from('Chat_available c') ->where('c.User.Roles.role_id = ?', 7) ->groupBy('c.id') ->orderBy('c.created_at ASC') ->fetchOne(); Now I need to get the user that waited the longest but this does NOT work $admin = Doctrine_Query::create() ->select('c.id') ->from('Chat_available c') ->where('c.User.Roles.role_id != ?', 7) ->groupBy('c.id') ->orderBy('c.created_at ASC') ->fetchOne();

    Read the article

  • DQL delete from multiple tables (doctrine)

    - by singer
    Need to perform DQL delete from multple related tables. In SQL it is something like this: DELETE r1,r2 FROM ComRealty_objects r1, com_realty_objects_phones r2 WHERE r1.id IN (10,20) AND r2.id_object IN (10,20) I need to perform this statement using DQL, but I'm stuck on this :( <?php $dql = Doctrine_Query::create() ->delete('phones, comrealtyobjects') ->from('ComRealtyObjects comrealtyobjects') ->from('ComRealtyObjectsPhones phones') ->whereIn("comrealtyobjects.id", $ids) ->whereIn("phones.id_object", $ids); echo($dql->getSqlQuery()); ?> But DQL parser gives me this result: DELETE FROM `com_realty_objects_phones`, `ComRealty_objects` WHERE (`id` IN (?) AND `id_object` IN (?)) Searching google and stack overflow I found this(useful) topic: http://stackoverflow.com/questions/2247905/what-is-the-syntax-for-a-multi-table-delete-on-a-mysql-database-using-doctrine But this is not exactly my case - there was delete from single table. If there is a way to override dql parser behaviour? Or maybe some other way to delete records from multiple tables using doctrine. Note: If you are using doctrine behaviours(Doctrine_Record_Generator) you need first to initialize those tables using Doctrine_Core::initializeModels() to perform DQL operations on them.

    Read the article

  • Where do DQL statements live in an application that is using Zend Framework and Doctrine

    - by Dewayne
    In an application that is using Zend Framework 1.10 and Doctrine 1.2, where should the DQL statements live if our application is built such that it has a Service Layer and a Gateway(aka Doctrine_Table) layer. It seems that our possibilities include: 1) Placing the DQL statements in the Service layer which seems to be a bit too high in our application hierarchy to store DQL. 2) Placing the DQL statements within each model's Table/Gateway which seems a bit redundant because we also need to expose the DQL statements that do things such as getAllUsers() through the Service layer. Which of these is a preferable design? We intend to make use of the Service layer as much as possible so that other projects might consume various parts of our application.

    Read the article

  • Doctrine: Unknown table alias. Is this DQL correct?

    - by ropstah
    I'm trying to execute a query but I get an error: Unknown table alias The tables are setup as follows: Template_Spot hasOne Template Template hasMany Template_Spot Template hasMany Location Location hasOne Template I'm trying to execute the following DQL: $locationid = 1; $spots = Doctrine_Query::create() ->select('cts.*, ct.*, uc.*') ->from('Template_Spot cts') ->innerJoin('Template ct') ->innerJoin('Location uc') ->where('uc.locationid = ?', $locationid)->execute(); Does anyone spot a problem?

    Read the article

  • How can get unique values from data table using dql?

    - by piemesons
    I am having a table in which there is a column in which various values are stored.i want to retrieve unique values from that table using dql. Doctrine_Query::create() ->select('rec.school') ->from('Records rec') ->where("rec.city='$city' ") ->execute(); Now i want only unique values. Can anybody tell me how to do that... Edit Table Structure: CREATE TABLE IF NOT EXISTS `records` ( `id` int(11) NOT NULL AUTO_INCREMENT, `state` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `school` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=16334 ; This is the Query I am using: Doctrine_Query::create() ->select('DISTINCT rec.city') ->from('Records rec') ->where("rec.state = '$state'") // ->getSql(); ->execute(); Generting Sql for this gives me: SELECT DISTINCT r.id AS r__id, r.city AS r__city FROM records r WHERE r.state = 'AR' Now check the sql generated:::: DISTINCT is on 'id' column where as i want Distinct on city column. Anybody know how to fix this. EDIT2 Id is unique cause its an auto incremental value.Ya i have some real duplicates in city column like: Delhi and Delhi. Right.. Now when i am trying to fetch data from it, I am getting Delhi two times. How can i make query like this: select DISTINCT rec.city where state="xyz"; Cause this will give me the proper output. EDIT3: Anybody who can tell me how to figure out this query..???

    Read the article

  • Doctrine Join DQL

    - by koko
    I's like to do a join between 2 tables on a specific ID. At the moment, I have this DQL: $q = Doctrine_Query::create() ->select('e.*, i.itemName, i.itemtypeId') ->from('Model_EventItem e') ->leftJoin('Model_Item i ON e.itemId = i.itemId') ->where('e.eventitemId = ?', $event->eventId) ->orderBy('i.itemName ASC'); The result is empty, although my eventId has a value ... Can you help me please? I there somewhere a tutorial on DQL-joins? I don't get it right with the help of the Doctrine documentation. Thanks! PS I have doctrine working in combination with Zend Framework.

    Read the article

  • Doctrine DQL execute passing params

    - by Karim web Developer
    I used this DQL in Doctrine $q->update('product') ->set('quantity','?') ->where('id=?'); $q->execute(array(20,5)); I check the server for the query and this the generated sql UPDATE product SET quantity = '20', updated_at = '5' WHERE (id = '2010-04-26 14:34); So I need to know why the arguments aren't in the correct places?

    Read the article

  • DATE_FORMAT in DQL symfon2

    - by schurtertom
    I would like to use some MySQL functions such as DATE_FORMAT in my QueryBuilder. I saw this post did not understand totally how I should achieve it: SELECT DISTINCT YEAR Doctrine class SubmissionManuscriptRepository extends EntityRepository { public function findLayoutDoneSubmissions( $fromDate, $endDate, $journals ) { if( true === is_null($fromDate) ) return null; $commQB = $this->createQueryBuilder( 'c' ) ->join('c.submission_logs', 'k') ->select("DATE_FORMAT(k.log_date,'%Y-%m-%d')") ->addSelect('c.journal_id') ->addSelect('COUNT(c.journal_id) AS numArticles'); $commQB->where("k.hash_key = c.hash_key"); $commQB->andWhere("k.log_date >= '$fromDate'"); $commQB->andWhere("k.log_date <= '$endDate'"); if( $journals != null && is_array($journals) && count($journals)>0 ) $commQB->andWhere("c.journal_id in (" . implode(",", $journals) . ")"); $commQB->andWhere("k.new_status = '20'"); $commQB->orderBy("k.log_date", "ASC"); $commQB->groupBy("c.hash_key"); $commQB->addGroupBy("c.journal_id"); $commQB->addGroupBy("DATE_FORMAT(k.log_date,'%Y-%m-%d')"); return $commQB->getQuery()->getResult(); } } Entity SubmissionManuscript /** * MDPI\SusyBundle\Entity\SubmissionManuscript * * @ORM\Entity(repositoryClass="MDPI\SusyBundle\Repository\SubmissionManuscriptRepository") * @ORM\Table(name="submission_manuscript") * @ORM\HasLifecycleCallbacks() */ class SubmissionManuscript { ... /** * @ORM\OneToMany(targetEntity="SubmissionManuscriptLog", mappedBy="submission_manuscript") */ protected $submission_logs; ... } Entity SubmissionManuscriptLog /** * MDPI\SusyBundle\Entity\SubmissionManuscriptLog * * @ORM\Entity(repositoryClass="MDPI\SusyBundle\Repository\SubmissionManuscriptLogRepository") * @ORM\Table(name="submission_manuscript_log") * @ORM\HasLifecycleCallbacks() */ class SubmissionManuscriptLog { ... /** * @ORM\ManyToOne(targetEntity="SubmissionManuscript", inversedBy="submission_logs") * @ORM\JoinColumn(name="hash_key", referencedColumnName="hash_key") */ protected $submission_manuscript; ... } any help I would appreciate a lot. EDIT 1 I have now successfully be able to add the Custom Function DATE_FORMAT. But now if I try with my Group By I get the following Error: [Semantical Error] line 0, col 614 near '(k.logdate,'%Y-%m-%d')': Error: Cannot group by undefined identification variable. Anyone knows about this?

    Read the article

  • Doctrine Update by DQL + field with parenthesis: "(" and ")"

    - by Paulo
    Hello! I have a doctrine update query to save my data: $customer = Doctrine_Query::create() -update('Customer') -set('fax',"'". $this-getRequest()-getParam('fax')."'") -where('id ='.$this-getRequest()-getParam('id')) -execute(); The problem is that the field fax has parenthesis and doctrine returns an error in the query because of these parenthesis "(" and ")". Somebody knows a solution for this? Thank's

    Read the article

  • Check if hydrated doctrine result is NULL

    - by iggnition
    Hi, I'm trying to check if a result in my DQL is NULL. I got the following DQL query: $q = self::createQuery("l") ->select('i.*, s.aantal, m.naam, c.cat_naam, a.app_id') ->from('InstalledBase i, i.Spare s, i.Apparaat a, a.Categorie c, a.Merk m') ->execute(); return $q; Now i want to check if the s.aantal is NULL so i do: if(is_null($installedbase->Spare->spare_id)) when the variable is NOT null everything works, but when it is actually NULL i get a E notice message: Notice: Trying to get property of non-object in \installedbase\templates\_index.php on line 29 It does see that it is null though because the if condition is executed. Weird thing is i'm doing the exact same thing on another page where it works no problem. But i must be doing something wrong or stupid since those messages generally don't show for nothing. So can anybody explain this to me? :)

    Read the article

  • What'd be a good pattern on Doctrine to have multiple languages

    - by PERR0_HUNTER
    Hi! I have this challenge which consist in having a system that offers it's content in multiple languages, however a part of the data contained in the system is not translatable such as dates, ints and such. I mean if I have a content on the following YAML Corporativos: columns: nombre: type: string(254) notnull: true telefonos: type: string(500) email: type: string(254) webpage: type: string(254) CorporativosLang: columns: corporativo_id: type: integer(8) notnull: true lang: type: string(16) fixed: false ubicacion: type: string() fixed: false unsigned: false primary: false notnull: true autoincrement: false contacto: type: string() fixed: false unsigned: false primary: false notnull: true autoincrement: false tipo_de_hoteles: type: string(254) fixed: false unsigned: false primary: false notnull: true autoincrement: false paises: type: string() fixed: false unsigned: false primary: false notnull: true autoincrement: false relations: Corporativo: class: Corporativos local: corporativo_id foreign: id type: one foreignAlias: Data This would allow me to have different corporative offices, however the place of the corp, the contact and other things can be translate into a different language (lang) Now this code here would create me a brand new corporative office with 2 translations $corporativo = new Corporativos(); $corporativo->nombre = 'Duck Corp'; $corporativo->telefonos = '66303713333'; $corporativo->email = '[email protected]'; $corporativo->webpage = 'http://quack.com'; $corporativo->Data[0]->lang = 'en'; $corporativo->Data[0]->ubicacion = 'zomg'; $corporativo->Data[1]->lang = 'es'; $corporativo->Data[1]->ubicacion = 'zomg amigou'; the thing now is I don't know how to retrieve this data in a more friendly way, because if I'd like to access my Corporative info in english I'd had to run DQL for the corp and then another DQL for the specific translation in english, What I'd love to do is have my translatable fields available in the root so I could simply access them $corporativo = new Corporativos(); $corporativo->nombre = 'Duck Corp'; $corporativo->telefonos = '66303713333'; $corporativo->email = '[email protected]'; $corporativo->webpage = 'http://quack.com'; $corporativo->lang = 'en'; $corporativo->ubicacion = 'zomg'; this way the translatable fields would be mapped to the second table automatically. I hope I can explain my self clear :( any suggestions ?

    Read the article

  • Doctrine_Query update with float value

    - by YS-PRO
    I need to increment User's balance, so I do: Doctrine_Query::create()->from('User')->update('balance', 'balance + 0.15')->execute(); And I got an error "Unknown component alias 0". I think its because of 0.15 So how can I update (using DQL) balance without additional SELECT queries to User's table to fetch his balance, calculate new balance and do query like Doctrine_Query::create()->from('User')->update('balance', '?', $new_balance)->execute();

    Read the article

  • Doctrine: Multiple (whereIn OR whereIn) query?

    - by Tom
    I'm having trouble crafting a fairly simple query with Doctrine... I have two arrays ($countries, $cities) and I need to check whether database record values would match any inside either. I'm looking for something like: ->whereIn('country', 'city', $countries, $cities) ... with 'country' being a WHERE IN for $countries and 'city' being a WHERE IN for $city. I could separate the two out but the needed query has lots of other conditions so that's not possible. The resulting SQL I'm after would be: SELECT ... WHERE ... AND ... AND ... AND ('country' IN (1,2,3) OR 'city' IN (7,8,9)) AND ... AND ...; One could therefore think of it also as a bracketing issue only. Anyone know if this is possible with Doctrine DQL? I've looked through the documentation but can't find any direction. Thanks

    Read the article

  • Doctrine2: Filtering by ManToMany Association

    - by Shroder
    I want to retrieve a collection of objects based on what they are associated to. For example, by a category. This would be a Many to Many relationship. I've been able to achieve that with MEMBER OF, however I need to pass in an array of IDs, opposed to one at a time. I see there is an "IN ()", but it seems to require a subquery, which I would like to avoid. MEMBER OF example: SELECT o FROM Entity\Object1 o WHERE 'CATEGORY_CODE' MEMBER OF o.categories (Edit) This is what I would like to do, but perhaps I'm misunderstanding how entities work in DQL: SELECT o FROM Entity\Object1 o WHERE o.categories.Id IN (id, id, id)

    Read the article

  • Is this possible to join tables in doctrine ORM without using relations?

    - by piemesons
    Suppose there are two tables. Table X-- Columns: id x_value Table Y-- Columns: id x_id y_value Now I dont want to define relationship in doctrine classes and i want to retrieve some records using these two tables using a query like this: Select x_value from x, y where y.id="variable_z" and x.id=y.x_id; I m not able to figure out how to write query like this in doctrine orm EDIT: Table structures: Table 1: CREATE TABLE IF NOT EXISTS `image` ( `id` int(11) NOT NULL AUTO_INCREMENT, `random_name` varchar(255) NOT NULL, `user_id` int(11) NOT NULL, `community_id` int(11) NOT NULL, `published` varchar(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=259 ; Table 2: CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `city` varchar(20) DEFAULT NULL, `state` varchar(20) DEFAULT NULL, `school` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ; Query I am using: $q = new Doctrine_RawSql(); $q ->select('{u.*}, {img.*}') ->from('users u LEFT JOIN image img ON u.id = img.user_id') ->addComponent('u', 'Users u') ->addComponent('img', 'u.Image img') ->where("img.community_id='$community_id' AND img.published='y' AND u.state='$state' AND u.city='$city ->orderBy('img.id DESC') ->limit($count+12) ->execute(); Error I am getting: Fatal error: Uncaught exception 'Doctrine_Exception' with message 'Couldn't find class u' in C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php:290 Stack trace: #0 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php(240): Doctrine_Table- >initDefinition() #1 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php(1127): Doctrine_Table->__construct('u', Object(Doctrine_Connection_Mysql), true) #2 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\RawSql.php(425): Doctrine_Connection- >getTable('u') #3 C:\xampp\htdocs\fanyer\doctrine\models\Image.php(33): Doctrine_RawSql- >addComponent('img', 'u.Image imga') #4 C:\xampp\htdocs\fanyer\community_images.php(31): Image->get_community_images_gallery_filter(4, 0, 'AL', 'ALBERTVILLE') #5 {main} thrown in C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php on line 290

    Read the article

  • Symfony 1.4/ Doctrine; n-m relation data cannot be accessed in template (indexSuccess)

    - by chandimak
    I have a database with 3 tables. It's a simple n-m relationship. Student, Course and StudentHasCourse to handle n-m relationship. I post the schema.yml for reference, but it would not be really necessary. Course: connection: doctrine tableName: course columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false name: type: string(45) fixed: false unsigned: false primary: false notnull: false autoincrement: false relations: StudentHasCourse: local: id foreign: course_id type: many Student: connection: doctrine tableName: student columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false registration_details: type: string(45) fixed: false unsigned: false primary: false notnull: false autoincrement: false name: type: string(30) fixed: false unsigned: false primary: false notnull: false autoincrement: false relations: StudentHasCourse: local: id foreign: student_id type: many StudentHasCourse: connection: doctrine tableName: student_has_course columns: student_id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false course_id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false result: type: string(1) fixed: true unsigned: false primary: false notnull: false autoincrement: false relations: Course: local: course_id foreign: id type: one Student: local: student_id foreign: id type: one Then, I get data from tables in executeIndex() from the following query. $q_info = Doctrine_Query::create() ->select('s.*, shc.*, c.*') ->from('Student s') ->leftJoin('s.StudentHasCourse shc') ->leftJoin('shc.Course c') ->where('c.id = 1'); $this->infos = $q_info->execute(); Then I access data by looping through in indexSuccess.php. But, in indexSuccess I can only access data from the table Student. <?php foreach ($infos as $info): ?> <?php echo $info->getId(); ?> <?php echo $info->getName(); ?> <?php endforeach; ?> I expected, that I could access StudentHasCourse data and Course data like the following. But, it generates an error. <?php echo $info->getStudentHasCourse()->getResult()?> <?php echo $info->getStudentHasCourse()->getCourse()->getName()?> The first statement gives a warning; Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Doctrine_Collection' does not have a method 'getCourse' in D:\wamp\bin\php\php5.3.5\PEAR\pear\symfony\escaper\sfOutputEscaperObjectDecorator.class.php on line 64 And the second statement gives the above warning and the following error; Fatal error: Call to a member function getName() on a non-object in D:\wamp\www\sam\test_doc_1\apps\frontend\modules\registration\templates\indexSuccess.php on line 5 When I check the query from the Debug toolbar it appears as following and it gives all data I want. SELECT s.id AS s__id, s.registration_details AS s__registration_details, s.name AS s__name, s2.student_id AS s2__student_id, s2.course_id AS s2__course_id, s2.result AS s2__result, c.id AS c__id, c.name AS c__name FROM student s LEFT JOIN student_has_course s2 ON s.id = s2.student_id LEFT JOIN course c ON s2.course_id = c.id WHERE (c.id = 1) Though the question is short, as all the information mentioned it became so long. It's highly appreciated if someone can help me out to solve this. What I require is to access the data from StudentHasCourse and Course. If those data cannot be accessed by this design and this query, any other methodology is also appreciated.

    Read the article

  • Using virtual fields in Doctrine_Query

    - by James Maroney
    Is there a way to insert logic based on virtual fields into a Doctrine_Query? I have defined a virtual field in my model, "getStatus()" which I would ultimately like to utilize in a Where clause in my Doctrine_Query. ... ->AndWhere('x.status = ?',$status); "status", however, is not a column in the table it is instead computed by business logic in the model. Filtering the Collection after executing the query works in some situations, but not when a Doctrine_Pager is thrown in the mix, as it computes it's offsets and such before you have access to the Collection. Am I best off ditching Doctrine_Pager and rebuilding that functionality after modifying the Doctrine_Collection?

    Read the article

  • How to make a nested query with an Entity that doesn't really exist (many-to-many)

    - by Calou
    Hi everyone, I'm new with Doctrine2 so my question can be easy to answer (I hope so). First of all, here the SQL query that I'd want : SELECT * FROM Document WHERE id NOT IN (SELECT document_id FROM Documents_Folders) Pretty simple isn't it ? The porblem is that my table 'Documents_Folders' is not an entity. In fact, it was create because I have a many-to-many relation between my entities 'Document' and 'Folder'. I tried several queries, but none worked. Thanks.

    Read the article

  • SQL, problem with OrderBy / GroupBy

    - by Tristan
    Hi, In my table I have two fields among others : article_id and *version* *example: article_id : 5 // version 1 aricle_id: 5 // version 2 article_id: 6 // version 1* What i want to do is to retrieve the latest version for each article id (in my example i want to retrieve the article 5 version 2 object and article 6 and version 1 object). The problem is that mysql is doing the groupBy instead of the OrderBy so it returns to me the FIRST version of each article, but i want the opposit. Do you have an idea please ?

    Read the article

  • Compare values in serialized column in Doctrine with Query Builder

    - by ReynierPM
    I'm building a FormType for a Symfony2 project but I need some Query Builder on the field since I need to compare some values with the one stored on DB and show the results. This is what I have: .... ->add('servicio', 'entity', array( 'mapped' => false, 'class' => 'ComunBundle:TipoServicio', 'property' => 'nombre', 'required' => true, 'label' => false, 'expanded' => true, 'multiple' => true, 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('ts') ->where('ts.tipo_usuario = (:tipo)') ->setParameter('tipo', 1); } )) .... But tipo_usuario at DB table is stored as serialized text for example: record1: value1 | a:1:{i:0;s:1:"1";} record2: value2 | a:4:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"3";i:3;s:1:"4";} I'll have two different forms (I don't know how to pass the Request to a form) in the first one I'll only show the first record and for the second one the first and second record for example: First form will show: checkbox: value1 Second form will show: checkbox: value1 checkbox: value2 I achieve this? Any help?

    Read the article

  • Using multiple aggregate functions in an (ANSI) SQL statement

    - by morpheous
    I have aggregate functions foo(), foobar(), fredstats(), barneystats() I want to create a domain specific query language (DSQL) above my DB, to facilitate using a domain language to query the DB. The 'language' comprises of algebraic expressions (or more specifically SQL like criteria) which I use to generate (ANSI) SQL statements which are sent to the db engine. The following lines are examples of what the language statements will look like, and hopefully, it will help further clarify the concept: **Example 1** DQL statement: foobar('yellow') between 1 and 3 and fredstats('weight') > 42 Translation: fetch all rows in an underlying table where computed values for aggregate function foobar() is between 1 and 3 AND computed value for AGG FUNC fredstats() is greater than 42 **Example 2** DQL statement: fredstats('weight') < barneystats('weight') AND foo('fighter') in (9,10,11) AND foobar('green') <> 42 Translation: Fetch all rows where the specified criteria matches **Example 3** DQL statement: foobar('green') / foobar('red') <> 42 Translation: Fetch all rows where the specified criteria matches **Example 4** DQL statement: foobar('green') - foobar('red') >= 42 Translation: Fetch all rows where the specified criteria matches Given the following information: The table upon which the queries above are being executed is called 'tbl' table 'tbl' has the following structure (id int, name varchar(32), weight float) The result set returns only the tbl.id, tbl.name and the names of the aggregate functions as columns in the result set - so for example the foobar() AGG FUNC column will be called foobar in the result set. So for example, the first DQL query will return a result set with the following columns: id, name, foobar, fredstats Given the above, my questions then are: What would be the underlying SQL required for Example1 ? What would be the underlying SQL required for Example3 ? Given an algebraic equation comprising of AGGREGATE functions, Is there a way of generalizing the algorithm needed to generate the required ANSI SQL statement(s)? I am using PostgreSQL as the db, but I would prefer to use ANSI SQL wherever possible.

    Read the article

  • Combining aggregate functions in an (ANSI) SQL statement

    - by morpheous
    I have aggregate functions foo(), foobar(), fredstats(), barneystats() I want to create a domain specific query language (DSQL) above my DB, to facilitate using using a domain language to query the DB. The 'language' comprises of boolean expressions (or more specifically SQL like criteria) which I then 'translate' back into pure (ANSI) SQL and send to the underlying Db. The following lines are examples of what the language statements will look like, and hopefully, it will help further clarify the concept: **Example 1** DQL statement: foobar('yellow') between 1 and 3 and fredstats('weight') > 42 Translation: fetch all rows in an underlying table where computed values for aggregate function foobar() is between 1 and 3 AND computed value for AGG FUNC fredstats() is greater than 42 **Example 2** DQL statement: fredstats('weight') < barneystats('weight') AND foo('fighter') in (9,10,11) AND foobar('green') <> 42 Translation: Fetch all rows where the specified criteria matches **Example 3** DQL statement: foobar('green') / foobar('red') <> 42 Translation: Fetch all rows where the specified criteria matches **Example 4** DQL statement: foobar('green') - foobar('red') >= 42 Translation: Fetch all rows where the specified criteria matches Given the following information: The table upon which the queries above are being executed is called 'tbl' table 'tbl' has the following structure (id int, name varchar(32), weight float) The result set returns only the tbl.id, tbl.name and the names of the aggregate functions as columns in the result set - so for example the foobar() AGG FUNC column will be called foobar in the result set. So for example, the first DQL query will return a result set with the following columns: id, name, foobar, fredstats Given the above, my questions then are: What would be the underlying SQL required for Example1 ? What would be the underlying SQL required for Example3 ? Given an algebraic equation comprising of AGGREGATE functions, Is there a way of generalizing the algorithm needed to generate the required ANSI SQL statement(s)? I am using PostgreSQL as the db, but I would prefer to use ANSI SQL wherever possible.

    Read the article

1 2  | Next Page >