PHP & MySQL
Mysql optimize
smalest data type
horizon : split many columned table
vertical: split many rowed table
alway:
fewer read= faster result
———————
Coding guideline:
- KISS(keep it simple stupid)
-Using store procedure for a big performance boost
-isolate index fields in one side of equation
(ex:
bad: where TO_DAYS(created_date) - TO_DAYS(CURRENT_DATE() >7
better: where created_date > CURRENT_DATE() - INTERVAL 7 DAY
best: calculate CURRENT_DATE() - INTERVAL 7 DAY ->replace [...]
Finding Hidden Characters in a File
As well as the characters you can see in a web page (or any other text file), there are a whole host of hidden characters that you can’t see. Most of the time you don’t need to know where these characters are, which is why they are hidden in the first place. Occasionally though, perhaps [...]
How to get tags cloud from the database?
_sqls package:
function getTagsCloud( $oModel ){
$sSql = “SELECT
COUNT(tag_id) as quantity, tag_id, tag_name
FROM fa_tags
WHERE tag_key=”.EVENT_KEY.” GROUP BY tag_name ORDER BY tag_name LIMIT 0,30 “;
parent::execute_query($sSql, __LINE__, __FILE__);
}
_models package:
function getTagsCloud(){
$this->oDb->getTagsCloud( $this );
return $this->oDb;
}
_views package:
function showTagsCloud( $oModel ){
$mRes = $oModel->getTagsCloud();
$aTags = array();
$aTagIds = array();
while ( $aRows = $mRes->fetch_row() ){
$aTags[strtolower($aRows[tag_name])] = $aRows[quantity];
$aTagIds[$aRows[quantity]] = $aRows[tag_id];
}
// change these font sizes if you will
$iMaxSize [...]
Interact with INI file
Desc:
- Parse INI file
- Get Section
- Get Phrase
- Add new section
- Add new phrase
- Update section
- Update Phrase
- Remove Section
- Remove Phrase
- Update INI file
Source: \\office-server\Components\PHP\IniInteraction
Example:
<?
/**
* @desc For example of IniInteraction
*/
require_once( dirname(__FILE__).’/class.IniInteraction.php’);
/*
<topic> Example for IniInteraction </topic>
*/
$oIniInteraction = new IniInteraction( TRUE );
$oIniInteraction->setIniFile(dirname(__FILE__).’/Example.ini’);
$oIniInteraction->ParseINI();
# Read Phrases
echo ‘<b>Read all Phrases:</b> <br>’;
print_r( $oIniInteraction->getPhrases() );
echo ‘<hr>’;
# Read Section
echo ‘<b>Read one section [...]

Ta Duc Phuong


