Mehic.info

Category Archives: Web

Posts related to web design and programming web applications.

CakePhp – How to fetch root categories with childs associated

Very simple : /** * Get categories with childs by parent id * @return array */ public function getRootCategoriesHaveChilds(){ $conditions = array(‘Category.parent_id ‘ => 0); $fields = array(‘Category.*’,'(SELECT COUNT( cat2.id ) FROM categories AS cat2 WHERE cat2.parent_id = Category.id) as Total’ ); $group = array(‘Category.id HAVING Total>0’); return $this->find(‘all’, array(‘conditions’=>$conditions, ‘fields’=>$fields, ‘group’ => $group, ‘recursive’ […]

Read more

CakePhp – how to disable validation

Well, first you must know that almost all stuff in cakePHP is stored in arrays, from top-develop side of view. So basic way to disable validation on some model is very simple : $this->Model->validate = array(); // Stop validation on the model Happy coding!

Read more

php function mb_ucfirst

function mb_ucfirst($str){ $str = trim($str); $firstChar = mb_substr($str, 0 , 1 ,’UTF-8′); $firstChar = mb_strtoupper($firstChar, ‘UTF-8’); return $firstChar . mb_substr($str, 1, strlen($str) – 1, ‘UTF-8’); } happy coding

Read more

Jquery PJAX freeze

Well, we had an issue with pjax since all pjax calls have been finished with frozen page. Best way to illustrate “frozen page” is custom loader that is shown when pjax action is called and hided when pjax action finished its progress. But loader seems to stay on page, jquery functions don’t hide it and […]

Read more