Monday 21 January 2013

How to solve the "Fatal error: Cannot use string offset as an array"?

How to solve the "Fatal error: Cannot use string offset as an array"?

I create one function that provide the data by passing id to it.

I used this function in for loop and pass the ID's one by one.

From this function I got all data properly. But when I take this data into the variable in same for loop
I got "Fatal error: Cannot use string offset as an array".

To resolve this problem, I used another for loop.

But can I solve this problem by using only one for loop or any other option?


Wednesday 16 January 2013

After Upgrading phpmyadmin to newer version the client connection are not accepted
It displays

Forbidden

You don't have permission to access / on this server.

What can be done to resolve this?

Sunday 13 January 2013

How can we used date picker for every records(input box) that create when we clone.

How can we used date picker for every records(input box) that create when we clone.

For more explanation I give an example.

I have create one date picker that will create a calendar and through that we can select the date.
To use that date picker I have to assign it with text box id or class in ready function of jquery.

But when I cloned, It doesn't reflect the cloning text box.

How can I solve this problem?

Thursday 10 January 2013

What is the Best Approach to adopt OOP in PHP?

What is the Best Approach to adopt OOP in PHP?

What is the best practice for using OOP paradigm in PHP? To what extent, OOP paradigm should be forced? PHP supports OOP. But if we use close to a strict OOP paradigm, we end up compromising on performance and memory.

For example, we have classes named User and UserGroup. UserGroup will have properties like details about Group and contains its members. Best OOP approach is that members of group should be array of instance of User class. Each User has several properties. If we follow OOP approach, we will end up filling all the details of all users in that UserGroup. This will make a lot of queries to database degrading the performance and consume a lot more memory. In face we will not need the details of all users, but couple of them. Or only couple of properties at a time.

So what is the best practice to adapt OOP paradigm in PHP? To what extent, it should be forced?

Sunday 6 January 2013

How does one order results for a MySQL Query by how well they matched a given query.

How does one order results for a MySQL Query by how well they matched a given query.



Use the following ORDER rule


ORDER 
BY case when `ColumnName` LIKE 'FirstRelevance' then 1 else 0 end
+ case when `ColumnName` LIKE 'SecondRelevance' then 1 else 0 end
+ case when `ColumnName` LIKE 'ThirdRelevance' then 1 else 0 end
...
DESC