This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clean($string) { | |
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. | |
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. | |
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compair date from JSON | |
WHERE updated > JSON_UNQUOTE(json_column->'$.JSON_KEY_NAME') | |
##### | |
// SAVE JSON value in UPDATE query | |
// when don't know either JSON key have set value or not? | |
UPDATE table SET table_col = JSON_SET(COALESCE(table_col, '{}'), '$.JSON_KEY_NAME', 'json_values') | |
##### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(defined('CONSTANT_NAME')) { | |
// do yes | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Codeigniter | |
// In application/config/constant.php | |
$usr_data = array(1 => "a", 2 => "b", 3 => "c"); | |
// In any view | |
global $usr_data; | |
echo $usr_data[2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^yourwebsite.com [NC] | |
RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [L,R=301] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Creating Header and Footer Templates in Codeigniter | |
class Template_Loader extends CI_Loader { | |
public function template($template_name, $vars = array(), $return = FALSE) | |
{ | |
$content = $this->view('templates/header', $vars, $return); | |
$content .= $this->view($template_name, $vars, $return); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mage_Catalog_Block_Product_Mylist extends Mage_Catalog_Block_Product_List | |
{ | |
/** | |
* Retrieve loaded category collection | |
* | |
* @return Mage_Eav_Model_Entity_Collection_Abstract | |
*/ | |
protected function _getProductCollection() | |
{ | |
$collection = parent::_getProductCollection(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data_array = array( | |
array( | |
'ItemRef' => 20, | |
'ClassRef' => 'test1', | |
'Hours' => 20 | |
), | |
array( | |
'ItemRef' => 21, | |
'ClassRef' => 'test2', | |
'Hours' => 10 |