Oracle with PHP Doctrine Issues.
September 25, 2009 by Reboot · Leave a Comment
We had some issues with a PHP Doctrine deployment, one of which included a “ORA-01861: literal does not match format string.” message. We made a quick fix by changing the date fields into varchar but the proper fix is mentioned below:
Most likely “ORA-01861: literal does not match format string.”
happened because date format in database and doctrine is not the same.
In oracle default date format depends on your installation and most
likely it looks like this: 21-JUN-2009. So when doctrine inserts
atable object, it tries to set CREATED_AT column using ‘Y-m-d H:i:s’
format and you get an exception. To get around this problem you can
create connection listener that sets default date format on connect:
ALTER SESSION SET NLS_DATE_FORMAT=’YYYY-MM-DD HH24:MI:SS’ or
$connection->setDateFormat(). Ideally doctrine should automatically
set oracle date on connect.
Thanks Vadik56
http://groups.google.com/group/doctrine-user/browse_thread/thread/78d1d33576ab905f
Also it was pretty difficult to find the proper format of the oracle connection string, working example:
in config
dsn: oci://[user]:[password]@[server_url]/(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL=TCP)(HOST = [server_url])(PORT=1521))) (CONNECT_DATA=(SID=[namespace])))
or in code
doctrine.connection_string =
“oci://[user]:[password]@[server_url]/(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=[server_url])(PORT=1521))) (CONNECT_DATA=(SID=[namspace])))”
Thanks Bertrand
http://forum.symfony-project.org/index.php/m/71601/
and
http://www.doctrine-project.org/Doctrine_Connection_Oracle/1_1#method_setdateformat
To monitor queries, add an event listener:
$profiler = new Doctrine_Connection_Profiler();
$conn = Doctrine_Manager::connection();
$conn->setListener($profiler);
…
foreach ( $profiler as $event ) {
echo $event->getQuery();
}
…
http://stackoverflow.com/questions/841950/doctrine-profiler-does-not-catch-queries
JQuery Plugin Tip : LiveQuery!
September 25, 2009 by Reboot · Leave a Comment
http://docs.jquery.com/Plugins/livequery
Code examples will follow shortly ;-D
How To : Reset the Validation Rules on a Dynamic Form (JQuery + Validation Plugin)
I created an application which handles requests, after choosing a request type the form fields are fetched and a form is generated. It’s completely AJAX based, thus the page is never refreshed. I ran into a problem though, rules from previous form generations persisted between request changes. The answer is simple, add an empty “rules” property to the validate() call. Note that internally the Validate plugin stores the form validation information in the JQuery data space so my first shot was to erase this data, which didn’t work.
—————- code snippet from jquery.validate.js —————-
line 35 $.data(this[0], ‘validator’, validator);
—————- code snippet —————-
…
myform.validate({
rules: {}, // REQUIRED TO RESET THE RULES LIST!!
onkeyup: false,
onfocusout: false,
onclick: false,
submitHandler: function(form) {
…
—————- ajax-based validation method example —————-
jQuery.validator.addMethod(“validatepair”, function(value, element) {
var checkresult = false;
$.ajax({
url: “validation_url”,
async: false, // important!
data: {
“value1″:$(‘#value1id’).val(),
“value2″:$(‘#value2id option:selected’).val()
},
dataType: “jsonp”,
success: function(data){
checkresult = data.valid;
}
});
return checkresult;
}, “Value1 does not match with the choosen value2 option.”);
Fetch Oracle NLS Settings, Install Oracle Full Client in Zend Server.
Note that these results were not the ones I’d hoped for, the result was the installation of the full Oracle Instant client in PHP instead of the light version.
SELECT * FROM NLS_DATABASE_PARAMETERS;
| PARAMETER | VALUE | |
| 1 | NLS_LANGUAGE | AMERICAN |
| 2 | NLS_TERRITORY | AMERICA |
| 3 | NLS_CURRENCY | $ |
| 4 | NLS_ISO_CURRENCY | AMERICA |
| 5 | NLS_NUMERIC_CHARACTERS | ., |
| 6 | NLS_CHARACTERSET | WE8ISO8859P1 |
| 7 | NLS_CALENDAR | GREGORIAN |
| 8 | NLS_DATE_FORMAT | DD-MON-RR |
| 9 | NLS_DATE_LANGUAGE | AMERICAN |
| 10 | NLS_SORT | BINARY |
| 11 | NLS_TIME_FORMAT | HH.MI.SSXFF AM |
| 12 | NLS_TIMESTAMP_FORMAT | DD-MON-RR HH.MI.SSXFF AM |
| 13 | NLS_TIME_TZ_FORMAT | HH.MI.SSXFF AM TZR |
| 14 | NLS_TIMESTAMP_TZ_FORMAT | DD-MON-RR HH.MI.SSXFF AM TZR |
| 15 | NLS_DUAL_CURRENCY | $ |
| 16 | NLS_COMP | BINARY |
| 17 | NLS_LENGTH_SEMANTICS | BYTE |
| 18 | NLS_NCHAR_CONV_EXCP | FALSE |
| 19 | NLS_NCHAR_CHARACTERSET | AL16UTF16 |
| 20 | NLS_RDBMS_VERSION | 9.2.0.7.0 |
To replace the light with the full client in Zend Server, put the “oraociei11.dll” (full) into the __ZendServerInstallPath__\ZendServer\bin directory and remove or rename the “oraociicus11.dll” (light). These libraries can be found in oracle client installation.
About the Title!
September 19, 2009 by Reboot · Leave a Comment
A little background info on the title. I am a big fan of a British TV series called Bottom!
Eddie: Well, at least we got the duck.
Richie: The duck?
Eddie: Yeah, it’s made out of plastic.
Richie: Eddie, what in the name of Greek buggery is the use of a plastic duck??
Eddie: It floats in the bath.
Richie: Yes, but why?
Eddie: It’s hollow!
Richie: *sighs* Why the duck??
Eddie: It came free with the telly!
Richie: Eddie everything came free with the telly, we were looting! Why couldn’t you get a free telly with the telly?
Eddie: Well it would sink in the bath!
[Bottom - Episode: Carnival]
Zend Code Generator on Google Code
September 17, 2009 by Reboot · 4 Comments
I started a project to create a zend code generator. It’s a pretty basic 3 layer model that it generates right now, tests included. Take a look at http://code.google.com/p/zend-code-generator/
