CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to add custom fields to Sql query
Pages: [1]

Author Topic: How to add custom fields to Sql query  (Read 589 times)

Henry2009

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.6.10
  • CMS version: Drupal 7.41
  • MySQL version: 5
  • PHP version: 5
How to add custom fields to Sql query
February 20, 2016, 02:22:21 am
How to add custom fields to Sql query. I am creating extension dont want to change core code.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: How to add custom fields to Sql query
February 20, 2016, 07:34:21 am
Please provide details.
Try asking your question on the new CiviCRM help site.

Henry2009

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.6.10
  • CMS version: Drupal 7.41
  • MySQL version: 5
  • PHP version: 5
Re: How to add custom fields to Sql query
February 20, 2016, 11:02:11 am
I have created a extension that adds a textfield  to Activity search form. I want to do Full text search on this textfield with matching records from activity database tables
I am not sure how to pass this field as sql query. I have edited existing activity search form and i want its result to be combined along with full text  search result of  this  new textfield.
« Last Edit: February 20, 2016, 11:04:05 am by Henry2009 »

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Re: How to add custom fields to Sql query
March 01, 2016, 06:21:51 pm
Look at your database schema, either using the command line or PhpMyAdmin (or similar). You can look up the db table name via "custom field" api calls I believe, otherwise by MySQL queries on the custom field table.
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

dwarak17

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
    • Java training in chennai
  • CiviCRM version: 4
  • CMS version: 4
  • MySQL version: 5
  • PHP version: 4
Re: How to add custom fields to Sql query
March 11, 2016, 10:12:03 pm
Yes, that's quite easy:

select first_name,
       last_name,
       'test' as default_value, --<< a "virtual" column containing a character value
       42 as the_answer         --<< another column containing a numeric value
from table1
  join table2 on table1.id = table2.customer_id;
You should also stop using those outdated implicit joins in the WHERE clause. Use an explicit JOIN operator instead. It makes the queries more robust against accidentally forgotten join conditions.

Java training in chennai | Android training in chennai | Oracle dba Training in Chennai | Python Training in chennai
Java training in chennai | Android training in chennai

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to add custom fields to Sql query

This forum was archived on 2017-11-26.