By ajajmal006 on
Hi,
I need to execute this following query
"INSERT INTO `test2`.`orders` (
`unitid` ,
`contractid` ,
`qty` ,
`month` ,
`address`
)
SELECT u.unitid, 2,u.qty,3,u.address
FROM units u, towns t
WHERE t.contractid =2
AND u.townid = t.id
AND (U.UNITID,3) NOT IN (SELECT O.UNITID,O.MONTH FROM ORDERS O WHERE O.UNITID=U.UNITID AND O"
please could someone have a look at my query here i need to fetch the data from one table and insert into that in another one, so could you help me to execute this in custom field or php field
Comments
Re: Need to execute sql query in drupal
You need to pass your SQL queries through Drupal's db_query() function. Here are some details - http://api.drupal.org/api/function/db_query/6
Need to execute sql query in drupal
Hi,
Thankyou, can you please look at my query here i need to fetch the data from one table and insert into that in another one, so could you help me to execute this in " module view header php code field "
Re: Need to execute sql query in drupal
Do something like this:
Need to execute sql query in drupal
Thank you so much i have tried based on your reference
Here
1. Selecting datas from two tables are not working i need to make joins?
2. am i write the code for database connection properly ? because i need to insert this code in header php field is it necessary to write to database connection code?
Re: Need to execute sql query in drupal
The property names of the $data object should be like "nid", "field_bunit_supposed_quantity_value", etc.
It appears that you are importing data into a node type. In that case have a look at the migrate module.
Usually, people do not write code in settings.php and instead place custom code in custom modules. If you still want to code, then l'll suggest that you should grab a copy of "Pro Drupal Developement" or any other Drupal programming book and have a serious look. Thanks.
Thankyou
Hi Muhammad,
Thankyou so much i will go through that book..
Need to pass argument from one view to another
Hi Muhammad,
I need to pass the nodeid as a argument from one view to other view. Could you help me to solve this problem..
Need to pass argument from one view to another
Please have a look at Views's argument system - http://drupal.org/node/54455.
Thankyou
Hi muhamed,
thankyou i had done it...
Pass User id as Argument
Hi,
I am using user id as argument in a view and i am using login destination module to redirect the page according to the roles
Here is the code i am using
global $user;
if (in_array('Branch Employee', $user->roles)) {
return 'index/branchuser/';
}
in the return function "return 'index/branchuser/';" i need to get the current logged in userid. Could you help me to solve this problem.
Re: Pass User id as Argument
Try this variable: $GLOBALS['user']>uid