Joshua's Thoughts

quickbase php api examples

Tags: , , , , ,

i’ve had a few requests for examples of how to use the quickbase php api wrapper. so here goes:

setup the quickbase object with login info

include the library and setup the object by passing in username, password, true/false (xml/http), and dbID of the db/table you’ll be transacting with.

include_once('../includes/qb.php');
$quickbase = new QuickBase('username','password', true, 'dbID');

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
			array(
				'fid'	=> '15',
				'ev'	=> 'ex',
				'cri'	=> 'somevalue')
			 );

$results = $quickbase->do_query($queries, '', '', '3');

adding a record to a quickbase

this one is super easy. create an associative array with field id’s and values and then use the add_record method.

$fields = array(
			array(
				'fid'	=> '1',
				'value'	=> 'some value'),
			array(
				'fid'	=> '2',
				'value'	=> 'some value'),
			array(
				'fid'	=> '3',
'value'=>'some value')
						  );
$quickbase->add_record($fields);

edit a quickbase record

almost identical to add_record, setup the array and use the add_record method.

$fields = array(
			array(
				'fid'	=> '1',
				'value'	=> 'some value'),
			array(
				'fid'	=> '2',
				'value'	=> 'some value'),
			array(
				'fid'	=> '3',
'value'=>'some value')
						  );
$quickbase->edit_record($fields);

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
			array(
				'fid'	=> '15',
				'ev'	=> 'ex',
				'cri'	=> 'somevalue')
			 );

$results = $quickbase->do_query($queries, '', '', '5');

webex api php wrapper

Tags: , , , , , ,

i did some work this week with integrating webex into the quickbase website. as a result, i ended up putting together a wrapper for the webex xml api in order to speed up development time.

if you’re going to be using webex with php, check it out.

it doesn’t have full support for all api methods (yet), but if there’s enough interest, perhaps i’ll keep building on it in my “spare” (ha) time.

basic examples of usage here: http://blog.joshuamcginnis.com/2009/04/quickbase-php-api-examples/

csv to associative array

Tags: , , , ,

i’ve been working a major integration project with quickbase and vtrenz. one of the things i had to do this week was take a ~10K row csv, scrub the cells for specific length, and then ftp to a remote server.

so i wrote a php script that would connect to quickbase, pull down the csv, write it to file, open it, turn the csv into an array, scrub it, recreate the csv from the array, write it to file again, and then send it on it’s merry way ala ftp.

all of it was easy except turning the csv into an array. i didn’t want to step through each character looking for newlines or my delimeter (a comma) and i needed something that would use the first row of the csv as the column headings.

i was able to find some scripts on the web that half-way worked. in fact, the one i used before writing my own worked, it was just super slow and inefficient. it literally used a gig of memory for 5K records.

so here’s my solution for taking a very large csv, and using the first row to create a key=>value associative array.

function buildStock($File, $rID) {
  $handle = fopen($File, "r");
  $fields = fgetcsv($handle, 5000, ",");

  $y = 0;
  while($data = fgetcsv($handle, 5000, ",")) {
    $x = 0;
    foreach($data as $value) {
      $stock[$y][$fields[$x]] = $value;
        $x++;
     }
     $y++;
    }
   return $stock;
}

it now only takes a few seconds to turn a considerably large csv into an array. hope this helps someone out there.

QuickBase Support

Tags: , , , , ,

QuickBase Support

QuickBase Support

We’ve been tossing around the idea of revamping the support section of the QuickBase website for some time now. Yesterday, I took an hour and mocked-up what I thought could be one version of the support page. If you look closely, you’ll see that I borrowed from both the TurboTax and the Apple support sites.

timothy carbery of axis technology

Tags: , , , ,

on my way home from web 2.0 nyc, i met a very nice gentleman by the name of timothy carbery. he happens to be the president of axis technology, a consulting firm in boston, ma.

the conversation started when he noticed me reading a book on flex. turns out, axis does a lot of work for the financial sector that uses flex – which i though was pretty cool. they use salesforce (which of course prompted me to plug quickbase).

he was kind enough to even hear some of my business ideas. very cool! the big takeaway from timothy was that at some point, i need to take “the dive” and give it a shot.

i always like meeting successful people, especially when they’re kind enough to spread their knowledge to those eager to learn. here’s to networking! cheers.