Skip to content

Instantly share code, notes, and snippets.

@phpdave
phpdave / SQLCodeCompletionIdeas.sql
Last active August 29, 2015 14:11
Ideas for Code Completion of SQL for Netbeans IDE
s SELECT * FROM ${Table}
u UPDATE ${Table} SET ${columnValue} WHERE ${WhereClause}
d DELETE FROM ${Table} WHERE ${WhereClause}
i INSERT INTO ${Table} ${columns} VALUES (${values});
g GRANT ${Permissions} ON ${DbObject} ${ObjectName} TO ${User}
@phpdave
phpdave / PHPCLICL
Last active August 29, 2015 14:14
CL Program that takes in a Filename and passes it to PHP-CLI in the PASE environment (IBM i)
*************** Beginning of data ********************************************
PGM PARM(&FILENAME)
/* VARS */
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(80)
DCL VAR(&PHPCLIPATH) TYPE(*CHAR) LEN(128)
/* VARS FOR TRIM */
DCL VAR(&LEN) TYPE(*DEC) LEN(2 0)
DCL VAR(&NULL) TYPE(*CHAR) LEN(128) VALUE(X'00') /*TERMINATE VAR WITH NULL */
DCL VAR(&NULL1) TYPE(*CHAR) LEN(1) VALUE(X'00')
DCL VAR(&CHR15) TYPE(*CHAR) LEN(15)
@phpdave
phpdave / DB2 Commitment Control Isolation Level test.php
Last active August 29, 2015 14:14
Code to test out isolation level. While this program is running execute a SQL SELECT statement on the same table and see if you get less than 10,000 records at any point
<?php
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
for ($index = 0; $index < 10000; $index++)
{
$insertdata[] = array('test');
}
@phpdave
phpdave / IBM DB2 commitmentcontrol.php
Last active August 29, 2015 14:14
example of using commitment control in DB2. Not isolation levels don't appear to work.
<?PHP
//Add commitment control to the DB2 Connect by using i5_commit
//Apparently you can't set this using ini_set. Therefore this would have to be set in the PHP.ini
//ini_set('ibm_db2.i5_allow_commit',1);
ini_set('ibm_db2.autocommit',DB2_AUTOCOMMIT_OFF);
$options = array('i5_lib' => 'MYLIB','autocommit' => DB2_AUTOCOMMIT_OFF,'i5_commit' => DB2_I5_TXN_SERIALIZABLE);
//Connect to DB2 - Commitments wont take place until we call
//db2_commit($db2Connection) on the connection.
<?php
$server = db2_server_info( $db2Connection );
var_dump($server);exit();
//DFT_ISOLATION and ISOLATION_OPTION should be looked at
?>
@phpdave
phpdave / NetbeansReloadMozillaOnSave.ahk
Last active August 29, 2015 14:15
Simple script to refresh browser when you save a file in netbeans. You could modify the script to do even more advanced things if your proficient in AHK.
;Bind to CTRL+S key
~^S::
;If Netbeans is active (SunAwtFrame) is a class, you could change this to the actual title but you'll have to update the script more often
IfWinActive, ahk_class SunAwtFrame
{
;Msbox for debugging purposes. ; is used to comment it out
;MsgBox NetBeans Active
;Activate Firefox
@phpdave
phpdave / subNavMenuByPageID.php
Created March 3, 2015 21:56
Get nav menu ID by "page id" and build sub navigation menu for that parent - WordPress PHP code
<?php
//this code is located in themes/{theme name}/page-templates/mypagetemplate.php in an area where i want to output the menu
//Get the Post/Page Id of the parent
if ($post->post_parent)
{
//go through post ancestors to find parent
$ancestors = get_post_ancestors($post->ID);
$parentPostId = $ancestors[count($ancestors) - 1];
}
@phpdave
phpdave / GetColumnsAndNumberOfRows.sql
Last active August 29, 2015 14:18
get coulmns and record count in 1 SQL query
SELECT a.*, b.NumberOfRows
FROM MYTABLE a
CROSS JOIN (SELECT COUNT(*) AS NumberOfRows FROM MYTABLE) b
@phpdave
phpdave / unlinkTest.php
Created April 2, 2015 13:50
delete a file using unlink
<?php
if(unlink("test.txt"))
echo "true";
else
echo "false";
SELECT *
FROM MYTABLE
WHERE TRANSLATE (MYTABLE.MYFIELD, 'NNNNNNNNNNX', '1234567890N') = 'NNNNN' AND MYTABLE.MYFIELD<10000
--MYFIELD is a CHAR(5) field and is being compared against 5 'N's