An Issue in PHP Multidimensional Array

When assing an element of multidimensional array in PHP, such as:

$arr = array(array());
$idx = 0;
$arr['Key_1'][$idx] = $something;

indeed, there would be automatically generate another element in front:

$arr[0] = '';

As a result, there are two elements:

$arr[0] = '';
$arr['Key_1'][0] = 'something';

However, when keys do include [0], it would be no such issue. To fix up the problem, following code needs to be added before return the array:

unset($arr[0]);

Fatal error: Call to undefined function... In PHP

First of all, the information contained in this error message is correct. The error was caused by the caller unable to access the called function, thus regarded as undefined function. There are several possibilities:

1. The function called is located in different PHP file, and it is not included or required by the caller file.

2. The php built-in function called has been deprecated.

3. Having an issue of encapsulation. It often happened when caller itself is not instantiated, and tried to call the function directly. Even if both caller and called are in same class, the PHP rule of encapsulation still applies. To fix up this, the called function must be declared as static, and the calling method need to be:

CalledClass::CalledFunction(); (Method 1)

If it is located in same class of the caller, it can be:

self::CalledFunction(); (Method 2)

When the caller is the object or instantiated of the class, it is necessary to use dynamic way, though it may be a public static function:

$result = $this->calledFunction(); (Method 3)

It would become more complicated when the caller is an function located within an instantiated object. In this case, method 3 does not work. Rather, Method 2 should be used.

Summary:

1. When caller is instantiated and externally called dynamically:
Called function declaration must be public.
Calling method: $instantiatedObject->calledFunction();

2. When caller is instantiated and externally called, and called function declared as static:
Called function declaration would be public static.
Calling method: $instantiatedObject->calledFunction();

3. When caller is not instantiated and externally called:
Called function declaration must be public static, or public when function is not within the class.
Calling method: $className::calledFunction(); or calledFunction(); when function is not within the class.

4. When caller is part of constructor and use dynamic method:
Called function declaration should be: private
Calling method: $this->calledFunction();

5. When caller is part of constructor and called function declared as static:
Called function declaration would be: private static
Calling method: $this->calledFunction();
This is not recommended.

6. When caller is internally located in another function, and called function declared as static:
Called function declaration should be: private static
Calling method: self::calledFunction();

There should be no other circumstances.


http://stackoverflow.com/questions/2220809/calling-a-method-from-another-method-in-same-php-class

IE Progress Bar Is Loading...

It would never have finished. Most likely it is caused by multiple iFrames within a page. It supposed oK, but IE never have fixed this bug. The problem is where you put some content in an iframe and the content finishes loading in the iframe but the ie status bar keeps loading.

* Create a blank.html file in the root web directory. This file need not contain anything.
* Create an invisible iframe in your page by setting frameborder="0" and style="height: 0; width: 0"
* After the Javascript code that loads the iframe, add the following line:
setTimeout("document.getElementById('ifrDummy').src = 'blank.html'", 100);

No more problems. This solution is provided by Rizal Almashoor. Please note, following solution sometimes does not work:

‹body onload="javascript:fixprogressbar()"›

where fixprogressbar was a javascript function

function fixprogressbar()
{
top.garbageframe.document.write("");
top.garbageframe.close();
return
}


http://www.rizalalmashoor.com/blog/ie-progress-bar-loading-forever-for-iframe/
http://www.pcreview.co.uk/forums/thread-2161806.php

Common Resolution for Background Image

The current highest resolution standard is WHUXGA, for which the resolution is 7680x4800. The most common resolutions at this point of time is 1280x1024 (19.10%) and 1680x1050 (18.23%). Practically, 1920x (15.61%) would be trend. In market, LCD monitor with resolution of 2560x1600 had been offered years.

At conclusion, your program for background image resolution should be either 1920x1200 or 2560x1600 (4 megapixels).


http://en.wikipedia.org/wiki/List_of_common_resolutions
http://en.wikipedia.org/wiki/Computer_resolution

Error Message: [rsInvalidDataSetName] The table ‘table1’ refers to an invalid DataSetName...

In SQL Server Reporting Services 2005, when you changed a dataset name or try to point to another dataset name, this error message is often generated as a result. That is right, you have referred to wrong dataset. The problem is it is hard to find where you can change this reference.

First, you need to remember your report may consist of several tables. Each of them usually refers to a different dataset. So, you need to click the table which does cause the trouble, then in Properties panel located at bottom right corner of your screen, to select that table, which is located right below caption “Properties”. In Data section, there is DataSetName. Select what you want.

Decimal Place in T-SQL

Sometime decimal place can drive you into mad in T-SQL because different machine can show different result.

In SELECT statement, a formula would generate a result without decimal place, because it had been automatically rounded to integer:

Value_Is_200/3 would generate 67

The easiest way to control decimal place is to place decimal point in one of the constants in your formula:

Value_Is_200/3.0 would generate 66.7
Value_Is_200/3.00 would generate 66.67

If it does not work, you can try:

ROUND(Value_Is_200/3.0, 1) would generate 66.7
ROUND(Value_Is_200/3.0, 2) would generate 66.67

It may not work sometimes, because ROUND() is not for the purpose of decimal control. If it does not work, or if you need to truncate rather than round, try:

ROUND(Value_Is_200/3.0, 2, 1) would generate 66.6
ROUND(Value_Is_200/3.0, 3, 2) would generate 66.66

Sometimes, it still does not work. Then try:

CONVERT(DECIMAL(12,1), Value_Is_200/3.0) would generate 66.7
CONVERT(DECIMAL(12,2), Value_Is_200/3.0) would generate 66.67
or
CONVERT(DECIMAL(12,1), ROUND(Value_Is_200/3.0, 2, 1)) would generate 66.6
CONVERT(DECIMAL(12,2), ROUND(Value_Is_200/3.0, 3, 2)) would generate 66.66

Show/Hide Fields In Crystal Reports Depends On The Parameter Selected

In Crystal Reports, multiple-value parameter is stored as array. To access each element, one can use format as {?FINANCIAL}[1], {?FINANCIAL}[2], etc.

Following is an example how to achieve this task:

Create a formula Show_Me as:

Global StringVar cShow;
cShow:={?FINANCIAL}[1];
If Count({?FINANCIAL})> 1 then cShow:=cShow+", " +{?FINANCIAL}[2];
If Count({?FINANCIAL})> 2 then cShow:=cShow+", " +{?FINANCIAL}[3];
If Count({?FINANCIAL})> 3 then cShow:=cShow+", " +{?FINANCIAL}[4];
If Count({?FINANCIAL})> 4 then cShow:=cShow+", " +{?FINANCIAL}[5];
If Count({?FINANCIAL})> 5 then cShow:=cShow+", " +{?FINANCIAL}[6];
If Count({?FINANCIAL})> 6 then cShow:=cShow+", " +{?FINANCIAL}[7];
If Count({?FINANCIAL})> 7 then cShow:=cShow+", " +{?FINANCIAL}[8];
If Count({?FINANCIAL})> 8 then cShow:=cShow+", " +{?FINANCIAL}[9];
If Count({?FINANCIAL})> 9 then cShow:=cShow+", " +{?FINANCIAL}[10];
If Count({?FINANCIAL})> 10 then cShow:=cShow+", " +{?FINANCIAL}[11];
cShow;

Then, for the fields which will be shown/hidden, program in ‘Suppress’ attribute:

If 'TG' In {@show_me} Then
false
Else
true

Here ‘TG’ is one value in parameter list.

Passing Multiple-Value Parameter To Oracle Procedure

Scenario:

Client wants to add new parameter - Transaction Reason.

At beginning, they want a drop down listing all the transaction reasons and ask for multiple value input.

As there are near 150 transaction reasons for claim, it is not a good way to list all the transaction reasons. For the drop down, it needs to create a view for select the reasons. And if new reason is added, we need to update the list. There will be a large maintenance work.

After further discuss with clients, no drop down for new parameter has reached the agreement: Letting the client enter transaction reason code. And allow multiple value input.

Analysis:

Since the report is from a stored procedure, the parameter of that procedure is automatically added to report as report parameter. In this case, one should add new parameter in procedure and use the parameter in ‘where’ statement.

However, Crystal Reports’ multiple-value parameter setting is disabled when report come from a stored procedure. Crystal will pass the multiple-value inputs as a string, such as transaction code: ’70, MO, MA, 40’.

The best possible solution is: Passing a comma-delimited string as one parameter and then parsing it in the stored procedure.

There are three methods to achieve this: using temporary table to store the after-parsing input list; and using table type to store the after-parsing input list. It is noticed however, when using table type (collection), it is hard to select a row as from a real table. On other hand, temporary table will slow the system. The third method is utilizing the Oracle built-in XML functions.

Solution:

Using Oracle existing XML functions:

• In order to use those XML functions, input string must in format delimited by comma:

'333,444,aaa'

• Replace the ',' with XML tag:

lv_Transaction_Reason_Code := '' Replace(Upper(Trim(Transaction_Reason_Code)), ',', '') '';

• Use XML functions to parse string and save into a table type collection.:

CREATE OR REPLACE TYPE TP_multi_value is Table Of VARCHAR2(10) Not Null;
lv_multi_value TP_multi_value;
Select Trim(t.EXTRACT('id/text()'))
Bulk Collect
Into lv_multi_value
From Table( XMLSequence(xmltype(lv_Transaction_Reason_Code).extract('//id'))) t
Where t.EXTRACT('id/text()') Is Not Null;

• In the ref_cursor use Table() function to change collection to a table for select from:
And
(lv_Transaction_Reason_Code Is Null
Or
tr.TRANSACTION_REASON_CODE In (Select t.column_value From Table (lv_multi_value) t)
) ;

• In report, add text to ask user enter code separated by ','.

• Need to show the selected transaction reason code in the report title. To do so, need to select correct formatted input string in back end:

lv_Reason_Code Varchar2(1000);
lv_Reason_Code := Upper(TRIM(Transaction_Reason_Code));
Open op_ObjCursor For
Select lv_StartDate StartDate
, lv_EndDate EndDate
, lv_Policy_number lv_Policy_number
, lv_Reason_Code Reason_Code
……

Then in report, show the code in title using formula:

Local StringVar sReasonCode;
If Isnull({PR_PAYMENTSRECOVERIES.REASON_CODE}) Then
sReasonCode := "All"
Else
sReasonCode := {PR_PAYMENTSRECOVERIES.REASON_CODE};
"Transaction Reason Code: " + sReasonCode + chr(13) +


Important tips:

• Trim the space from original input string;
• Only insert into collection the value is not null;
• Trim the space of each individual item before save into collection.
• Those XML function is deal with string. If need number, need To_number() as last.
• In report, edit parameter. Enter promoting text: Use comma to separate the code. For example: MA,70,40. (However, the promote text could not be saved with report. It is only one time show. This is the bug for Crystal X.)
• To display the code list, format the string at backend, then select this string available in cursor.

Labels