Why does some query that works in mysql doesn't work with db_query? For instance -
" SELECT * FROM {tb1},{tb2}WHERE {tb1}.vid=%d " (Of course I substitute %d with actual vid value while I'm testing in mysql environment)
"SELECT f1,f2,...,f10 FROM {tb1} INNER JOIN {tb2} ON {tb1}.vid = {tb2}.vid WHERE {tb1}.vid = %d AND {tb2}.vid = %d
Although I get 1 record returned in mysql environment for both statements, db_query doesn't return anything at all. Any idea what mistake I'm making? For what is worth, I'm using IIS 7.5, Mysql 5.5, php 5.2.12 *UPDATE* db_query/db_fetch_object work just fine. It just that hook_view isn't being invoke. So, as a result, no data is displayed. Sorry for the trouble.
UPDATED
function mymodule_load($node){
$query = 'SELECT f1,f2,...,f10 FROM {tb1} INNER JOIN {tb2} ON {tb1}.vid = {tb2}.vid WHERE {tb1}.vid = %d AND {tb2}.vid = %d';
$result = db_query($query,$node->vid);//If I use db_query($query,$node->vid,$node->vid), drupal doesn't invoke hook_view
drupal_set_message($node->vid,"status"); //for testing purpose
return db_fetch_object($result);
}
function mymodule_view($node, $teaser = FALSE, $page = FALSE){
$node = node_prepare($node, $teaser); // get it ready for display
$f1 = check_markup($node->f1);
..............
$f10 = check_markup($node->f10);
// Add theme stuff here
$node->content['mycontent'] = array(
'#value' => theme('defaultskin', $f1,...,$f10),
'#weight' => 1,
);
return $node;
}
function mymodule_theme(){
return array(
'defaultskin' => array(
'template' => 'node-defaultskin',
'arguments' => array(
'f1' => NULL,
......
'f10' => NULL,
),
),
);
}