NodeQ

Are you new to the eduTrac SIS online user's manual? If so, click here for a starting point. If you are looking for technical documentation, then check out the Wiki.

 

NodeQ is short for Node Queue. NodeQ is a noSQL database library which allows for queuing results to be used at a later time. For example, if you need to send out an email to a huge list, then it can be saved to a node/queue. Then instead of interacting with the MySQL to send out an email to a huge list, it can instead interact with NodeQ.

Import Node Class

use app\src\Core\NodeQ\etsis_NodeQ as Node;

Insert New Record

/**
 * INSERT new record will also create new node (person).
 * 
 * SQL Equivalent: INSERT INTO `person` (`uname`, `email`) VALUES ('teapott', 'teapott@gmail.com');
 */
$row = Node::table('person');
$row->personid = (int) 1;
$row->uname = (string) 'teapott';
$row->email = (string) 'teapott@gmail.com';
$row->fname = (string) 'Terry';
$row->lname = (string) 'Teapot';
$row->save();

Select All

/**
 * SELECT all records in `person` node.
 * 
 * SQL Equivalent: SELECT * FROM `person`;
 */
$table = Node::table('person')->findAll();
foreach($table as $row) {
 print_r($row);
}

Select All Based on Field

/**
 * SELECT all records in `person` node with matching field.
 * Field must exist.
 * 
 * SQL Equivalent: SELECT * FROM `person` WHERE `email` <> '';
 */
$row = Node::table('person')
 ->where('email', '!=', '')
 ->find();

echo $row->personid;

Update

/**
 * UPDATE `status` to active where email is not null.
 * 
 * SQL Equivalent: UPDATE `person` SET `status` = 'active' WHERE `email` <> '';
 */
$row = Node::table('person')
 ->where('email', '!=', '')
 ->find();

$row->status = (string) 'active';
$row->save();

Select by Primary Key

/**
 * SELECT record based on primary key (id).
 * 
 * SQL Equivalent: SELECT * FROM `person` WHERE `id` = '2';
 */
$row = Node::table('person')
 ->find(2);

Delete

/**
 * DELETE all records where `email` is null.
 * 
 * SQL Equivalent: DELETE FROM `person` WHERE `email` = '';
 */
$row = Node::table('person')
 ->where('email', '=', '')
 ->find()
 ->delete();

 

Last Modified: Oct 10, 2016 @ 7:23 PM

Was this article helpful?

Related Articles