Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the $adb object
#8
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:

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 )
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.
Reply


Messages In This Thread
Using the $adb object - Guido1982 - 11-10-2015, 05:33 PM
RE: Using the $adb object - Guido1982 - 11-10-2015, 08:11 PM
RE: Using the $adb object - joebordes - 11-10-2015, 10:12 PM
RE: Using the $adb object - Guido1982 - 11-11-2015, 10:47 AM
RE: Using the $adb object - joebordes - 11-11-2015, 02:50 PM
RE: Using the $adb object - Guido1982 - 11-11-2015, 03:46 PM
RE: Using the $adb object - joebordes - 11-11-2015, 10:09 PM
RE: Using the $adb object - Guido1982 - 11-11-2015, 10:15 PM
RE: Using the $adb object - joebordes - 11-11-2015, 11:00 PM
RE: Using the $adb object - Guido1982 - 11-11-2015, 11:49 PM
RE: Using the $adb object - joebordes - 11-12-2015, 07:26 AM
RE: Using the $adb object - Guido1982 - 11-12-2015, 07:14 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)