Archive for the ‘programming’ Category

For each database engine we have different ways to retrieve the last inserted id, let’s say that we have the following table:

Product(productID, name, description)

And we have the following query:

<cfquery name=”test” datasource=”my_data”>

insert into Product (name, description) values (‘someProd’, ‘description O fThe Prod’)


now for each engine we can get the last ID in the following way:

MSSQL: <cfoutput>#test.IDENTITYCOL#</cfoutput>

Oracle: <cfoutput>#test.ROWID#</cfoutput>



MySQL: <cfoutput>#test.GENERATED_KEY#</cfoutput>

I guess that this is because each engine uses different methods and the internal database variables are different from engine to engine.

MSSQL, where is NOW() from MySQL?

Posted: 18th May 2012 by admin in MSSQL

To get the current date-time on MSSQL we just have to use the function GETDATE():

select GETDATE();

This will display the same as the NOW() function from MySQL.

Function ereg() is deprecated in html2fpdf.php

Posted: 18th January 2011 by admin in programming

Since on PHP the function ereg is deprecated we should use:


But here is a catch!!!! since the POSIX regular expressions are different from the PCRE used in preg_match(), you need to replace:



preg_match(‘/^([^=]*)=[“\’]?([^”\’]*)[“\’]?$/’, $v, $a3)

Note that the / works as delimiter.

That’s all

session_start(): ps_files_cleanup_dir

Posted: 17th January 2011 by admin in programming

This happens when PHP does not have permission to write on the session directory, to correct this go to your /var/www directory and change the owner of the files to root like:

/var/www$ chown root.root myProjectDir -R

Where “myProjectDir” is the directory of the system that you are creating.

Using document.getElementById()

Posted: 2nd December 2010 by admin in programming

With document.getElemebtById() we can have access and modify the properties of any HTML element for instance if we have the following element:

<input id="myText" type="text" />

To access all it’s properties like style or value, we just refer to the element and make the change:

document.getElementById("myText").value = "Hello";

If you put this pieces of code into a page it will not work because there is no action that call the the assigned variable, to make a proper call we should create a function or place a button if you like: