CSS Tabs | unraveled
11/12/2012
11/06/2012
__PHP_Incomplete_Class Object vs __PHP_Incomplete_Class_Name
When you meet '__PHP_Incomplete_Class_Name' by using unserialize , please confirm whether you have included the class file in serialized contents before you use unserialize function.
For example:
Include class
Wrong Read file
Wrong Output
Correct Read File
Correct Output
For example:
Include class
/*SimpleClass.php*/Write file
class SimpleClass{
var $key;
function SimpleClass(){
}
function __set($name,$value){
$this->key[$name] = $value;
}
function __get($name){
return $this->key[$key];
}
}
?>
/*Store.php
*/
require_once './SimpleClass.php';
$SimpleClass = new SimpleClass;
$SimpleClass->keywords = 'Google';
@file_put_contents('./aaa.txt', serialize($SimpleClass));
?>
Wrong Read file
/*Read.php
*/
$SimpleClass = unserialize(file_get_contents('./aaa.txt'));
print_r($SimpleClass);
?>
Wrong Output
__PHP_Incomplete_Class ObjectIn order to resolve this problem, you have to include the class file in serialized contents before you use unserialize function.
(
[__PHP_Incomplete_Class_Name] => SimpleClass
[key] => Array
(
[keywords] => Google
)
)
Correct Read File
/*Read.php
*/
require_once './SimpleClass.php';
$SimpleClass = unserialize(file_get_contents('./aaa.txt'));
print_r($SimpleClass);
?>
Correct Output
SimpleClass Object
(
[key] => Array
(
[keywords] => Google
)
)
11/01/2012
resolutions for java version different from javac on centos 6.3
sudo java --verison
java version "1.6.0_24"
sudo javac --version //javac 1.7
javac 1.7.0_07
To install/ register a JVM use the following
1 /usr/sbin/alternatives --install "/usr/bin/java" "java" "/usr/java/default/bin/java" 2
2 /usr/sbin/alternatives --install "/usr/bin/javac" "javac" "/usr/java/default/bin/javac" 2
And to configure systemwide changes use
3 /usr/sbin/alternatives --configure java
or
/usr/sbin/alternatives --config java
4 /usr/sbin/alternatives --configure javac
or
/usr/sbin/alternatives --config javac
sudo java --verison
java version "1.7.0_07"
sudo javac --version //javac 1.7
javac 1.7.0_07
java version "1.6.0_24"
sudo javac --version //javac 1.7
javac 1.7.0_07
To install/ register a JVM use the following
1 /usr/sbin/alternatives --install "/usr/bin/java" "java" "/usr/java/default/bin/java" 2
2 /usr/sbin/alternatives --install "/usr/bin/javac" "javac" "/usr/java/default/bin/javac" 2
And to configure systemwide changes use
3 /usr/sbin/alternatives --configure java
or
/usr/sbin/alternatives --config java
4 /usr/sbin/alternatives --configure javac
or
/usr/sbin/alternatives --config javac
sudo java --verison
java version "1.7.0_07"
sudo javac --version //javac 1.7
javac 1.7.0_07
SQL_CALC_FOUND_ROWS + FOUND_ROWS()
When we want to list contents based on different pages, we have to do: one get a result set , another count the total number of rows. In general, we will use two query sql to complete this process.
1. SELECT id, title FROM articles WHERE TRUE LIMIT $limit, $start
2 SELECT count(id) as total FROM articles WHERE TRUE
From the above query, we may know the MySQL server will execute twice to scan all articles (query 1 will calculate result set size even when this is not needed). If the articles have more 1 million, the two queries need more times.
Fortunately, the MySQL server provide one methods to remember total records at executing the first query. So after executing the first, we just get the total records based on the first query, not executing the second query. Then we will save more half time. Now I give one example to complete this process.
3. SELECT SQL_CALC_FOUND_ROWS id, title FROM articles WHERE TRUE LIMIT $limit, $start
4. SELECT FOUND_ROWS() as total
The query 3 will scan all records, but the query 4 will not scan all records of the table. The executing efficiency will improve most.
For details about this method, please refer MySQL reference manual from http://dev.mysql.com/doc/refman/5.1/en/information-functions.html
Good luck.
1. SELECT id, title FROM articles WHERE TRUE LIMIT $limit, $start
2 SELECT count(id) as total FROM articles WHERE TRUE
From the above query, we may know the MySQL server will execute twice to scan all articles (query 1 will calculate result set size even when this is not needed). If the articles have more 1 million, the two queries need more times.
Fortunately, the MySQL server provide one methods to remember total records at executing the first query. So after executing the first, we just get the total records based on the first query, not executing the second query. Then we will save more half time. Now I give one example to complete this process.
3. SELECT SQL_CALC_FOUND_ROWS id, title FROM articles WHERE TRUE LIMIT $limit, $start
4. SELECT FOUND_ROWS() as total
The query 3 will scan all records, but the query 4 will not scan all records of the table. The executing efficiency will improve most.
For details about this method, please refer MySQL reference manual from http://dev.mysql.com/doc/refman/5.1/en/information-functions.html
Good luck.
Subscribe to:
Posts (Atom)