In that case there is some difference between the 'print_r' functionality from Smarty (what I'm used to work with).
I understand I need a loop to actually work with the results, but I thought print_r could give me exact details about the result, including all the rows. How should I visualize this 'record set', as an array, or an instance of a class? I'm asking this so I can solve this on my own from a better understanding next time.
In that case there is some difference between the 'print_r' functionality from Smarty (what I'm used to work with).
I understand I need a loop to actually work with the results, but I thought print_r could give me exact details about the result, including all the rows. How should I visualize this 'record set', as an array, or an instance of a class? I'm asking this so I can solve this on my own from a better understanding next time.
I noticed that when I use fetch_array on the result, assign that to a test var and then use "print_r" on that, it'll only give me something if I include the files you included in you example, but I don't understand why. I shall have to read the 'Module.php' file as well. I do understand the bringing in of the $adb instance from the global scope, didn't know I had to bring in the $current_user aswell.
You example is working, but I want to find the error in my thought process. For instance, using this:
Gives me:
But I don't understand why. I'd expect the fetch_array to return an array of all the rows I requested. Why does it only return one, and only makes it possible to visualize all rows when using a while loop? In Smarty using print_r just gives me the entire array or object, including lower levels.
NOTE:
If there is any documentation on the $adb object or generic method descriptions for this: I'm not too lazy to read, I just haven't found it yet.
I understand I need a loop to actually work with the results, but I thought print_r could give me exact details about the result, including all the rows. How should I visualize this 'record set', as an array, or an instance of a class? I'm asking this so I can solve this on my own from a better understanding next time.
In that case there is some difference between the 'print_r' functionality from Smarty (what I'm used to work with).
I understand I need a loop to actually work with the results, but I thought print_r could give me exact details about the result, including all the rows. How should I visualize this 'record set', as an array, or an instance of a class? I'm asking this so I can solve this on my own from a better understanding next time.
I noticed that when I use fetch_array on the result, assign that to a test var and then use "print_r" on that, it'll only give me something if I include the files you included in you example, but I don't understand why. I shall have to read the 'Module.php' file as well. I do understand the bringing in of the $adb instance from the global scope, didn't know I had to bring in the $current_user aswell.
You example is working, but I want to find the error in my thought process. For instance, using this:
PHP Code:
include_once('vtlib/Vtiger/Module.php');
global $current_user,$adb;
$query = "SELECT `invoiceid`, `subject`, 'subtotal' FROM `vtiger_invoice`";
$result = $adb->pquery($query,array());
$test = $adb->fetch_array($result);
print_r($test);
Gives me:
Code:
Array ( [0] => 89 [invoiceid] => 89 [1] => vtiger_invoice201 [subject] => vtiger_invoice201 [2] => subtotal [subtotal] => subtotal )
NOTE:
If there is any documentation on the $adb object or generic method descriptions for this: I'm not too lazy to read, I just haven't found it yet.