Tech Lull
 
 
JavaPHPSQLDrupalOpenGLMathematicsRenderings
 
 

Drupal Tip - cron breaks on drupal_goto
December 03, 2008

If you use drupal_goto within a node and have the search module enabled, when you go to index your site with cron, it will stop at the node redirect - and so will future crons. To get around this, you can put in conditionals like:

if ($_SERVER['SCRIPT_NAME'] != '/cron.php') { drupal_goto(); } view
Drupal Tip - Tablesort/pagequery with Custom ORDER BY Clause
October 22, 2008

I have a table pulled from database results which uses the drupal api to allow for sortable columns and theming. This is accomplished with tablesort_sql, page_query, and theme 'pager' and 'table' calls. The issues I came across were: 1) wanting to have a custom ORDER BY clause 2) only having this clause on a certain column 3) having the pager disappear after the first two things were implemented...

view
 
PHP Tip - PDO Error Handling
December 11, 2007

After establishing your PDO connection, set the following attribute:

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

this will throw an exception on PDO errors. now, you can wrap everything in a nice try/catch block

try{ }catch(PDOException $e){ echo $e->message(); } view
PHP Tip - PDO Transactions
December 11, 2007

To do DB transactions in PDO, first make sure your DB engine supports transactions. If you are using MySQL, then you need to alter your tables from the default engine to something like InnoDB. ALTER TABLE table_name ENGINE = innodb; let $db be your database handle with the PEAR API, you would of done something like:

try{ $db->autoCommit(false); ...statements.... $db->commit(); }catch(Exception $e){ $db->rollback(); } $db-><...view
 
PHP Tip - PDO Singleton Class
December 11, 2007

the singleton design pattern allows you to have one and only one instance of a class/object. it is good for large, shared resources like databases. <?php /** @author Brian Danchilla @brief PDO singleton class */ class PDO_DBConnect { static $db ; private $dbh ; private function PDO_DBConnect () { $db_type = 'pgsql'; //ex) mysql, postgresql, oracle $db_name = 'lc4f_central'; $user = 'brian' ; $password = '...

view
PHP Tip - Variables
August 15, 2007

Here are a couple problem/solutions of PHP variables. 1) You have an attribute of a object that you want to print. ex) $this->object_name->attribute

echo "$this->object_name->attribute";

will not parse as expected although

echo "$this->another_attribute";

would Solution: wrap the variable in curly brace {}

echo "{$this->object_name->...view