Example #1
0
 public static function getObject($ind)
 {
     if (!$ind) {
         return false;
     }
     if (is_numeric($ind)) {
         $key = 'id';
         $notUrl = ' and url=""';
         // дополнительная проверка на пустой урл для этого обьекта, что-бы небыло повторов страниц
     } else {
         $key = 'url';
         $ind = trim($ind, '/');
         if (!$ind) {
             return false;
         }
     }
     //   $objectModel = new Admin_Model_Object;
     //   $object = $objectModel->mfr(select()->where(array($key => $ind)));
     // select *,(select name from obj_types where id=obj_objects.type limit 1) as typename, (select anchID from obj_objects  where id=".$_REQUEST['look']."   limit 1) as filial_info, (select symbol from obj_branches where id=obj_objects.branchID) as letter from obj_objects where id=".$_REQUEST['look']." limit 1"
     //    $db->setQuery('select id,title,text from obj_plans where objID='.$this->data['id'].'');
     // phone, address, email
     $q = new K_Query();
     $row = $q->q("SELECT o.*, b.symbol letter, t.name typename, o.branchID filial_info, b.symbol letter, b.phone, b.address, b.email  FROM `obj_objects` o \n                        LEFT JOIN obj_rooms r ON r.id = o.id\n                        LEFT JOIN obj_types t ON t.id = o.type\n                        LEFT JOIN obj_branches b ON b.id = o.branchID \n                      WHERE o." . $key . "=" . K_Db_Quote::quote($ind) . ' ' . $notUrl, true);
     if ($row) {
         return $row[0];
     } else {
         return false;
     }
 }
Example #2
0
 /** Функция возврящяет сформированный массив where
  *   
  * 
  * 
  */
 public static function where($fields, $pts)
 {
     foreach ($fields as $k => $v) {
         if (isset($pts[$k]) && !empty($pts[$k])) {
             if ($_POST[$k] == "нет") {
                 $where[] = $v . ' IS NULL ';
             } else {
                 $where[] = $v . ' LIKE ' . K_Db_Quote::quote($_POST[$k] . '%');
             }
         }
     }
     return $where;
 }
Example #3
0
 public function loadCompletedFormsAction()
 {
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     $formData = Gcontroller::loadclientFormStructure(trim($_POST['tree_link']));
     /*    $clientFormData = $typeClientForm->fetchRow( K_Db_Select::create()->where( "type_clientform_id=$clientFormKey" ) );
           $this->view->formStructure=unserialize( $clientFormData['type_clientform_content'] );*/
     $formStructure = json_decode($formData['form_structure']);
     $formStructure = K_Tree_Types::objectToArray($formStructure);
     $fieldCount = 0;
     foreach ($formStructure as $v) {
         if (isset($v['values']['name']) && isset($v['values']['label'])) {
             $colsKeys[] = $v['values']['name'];
             $fieldCount++;
         }
         if ($fieldCount > 3) {
             break;
         }
     }
     $query = new K_Db_Query();
     $sql = "SELECT * FROM clientform_data WHERE clientform_data_type=" . K_Db_Quote::quote(trim($_POST['tree_link'])) . " ORDER by clientform_data_date DESC LIMIT {$start}, {$onPage}";
     $formsRes = $query->q($sql);
     $sql = "SELECT count(*) as countItems from clientform_data WHERE clientform_data_type=" . K_Db_Quote::quote(trim($_POST['tree_link']));
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $forms = array();
     foreach ($formsRes as $v) {
         $formData = array();
         $id = $v['clientform_data_id'];
         $formData[] = $v['clientform_data_date'];
         $data = unserialize($v['clientform_data_content']);
         $data = K_Tree_Types::objectToArray($data);
         foreach ($colsKeys as $n) {
             $formData[] = isset($data[$n]) ? $data[$n] : 'off';
         }
         $formData['id'] = $id;
         $forms[] = $formData;
     }
     $returnJson = array('error' => false, 'items' => $forms, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #4
0
 public static function balanceRemove($count)
 {
     self::init();
     //снимаем деньги со счёта
     $organizationModel = new Admin_Model_Organization();
     $organizationModel->update(array('organization_pay_balance' => K_Db_Quote::quote(K_Auth::getUserInfo('org_balance') - $count)), 'organization_id=' . K_Auth::getUserInfo('organization'));
     $journalData['p_org'] = K_Auth::getUserInfo('organization');
     $journalData['p_client'] = K_Auth::getUserInfo('id');
     $journalData['p_balance'] = K_Auth::getUserInfo('org_balance');
     $journalData['p_count'] = $count;
     $journalData['p_admins'] = 0;
     $journalData['p_users'] = 1;
     $journalData['p_acost'] = self::$_adminCost;
     $journal = new Admin_Model_PayJournal();
     $journal->save($journalData);
     K_Auth::setUserKey('org_balance', K_Auth::getUserInfo('org_balance') - $count);
 }
 public function loadtypesAction()
 {
     $query = new Query();
     $this->view->title = 'Добавление нового типа';
     $this->view->header = 'Добавление нового типа';
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     if (isset($_POST['name'])) {
         $where[] = 'type_name Like ' . K_Db_Quote::quote('%' . $_POST['name'] . '%');
     }
     if (isset($_POST['desc'])) {
         $where[] = 'type_desc Like ' . K_Db_Quote::quote('%' . $_POST['desc'] . '%');
     }
     if ($where && count($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = new Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM types {$where} order by type_name LIMIT {$start}, {$onPage}";
     $itemsRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $items = array();
     foreach ($itemsRes as $v) {
         $itemRow['type_id'] = $v['type_id'];
         $itemRow['name'] = htmlspecialchars($v['type_name']);
         $itemRow['desc'] = htmlspecialchars($v['type_desc']);
         $items[] = $itemRow;
     }
     $returnJson = array('error' => false, 'items' => $items, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #6
0
 public function loadAction()
 {
     $userModel = new Admin_Model_User();
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     $filter = $_POST['filter'];
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     $where = 'WHERE 1=1';
     if ($filter) {
         $where = "WHERE user_name like " . K_Db_Quote::quote($filter . '%');
     }
     $query = new K_Db_Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS u.*, (SELECT GROUP_CONCAT(role_name SEPARATOR ', ') as user_roles FROM users_roles ur left join role  on ur.usrol_role_id=role_id WHERE ur.usrol_user_id = u.user_id) as user_roles FROM users u  \n                {$where} order by user_name LIMIT {$start}, {$onPage}";
     $usersRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $users = array();
     foreach ($usersRes as $v) {
         $id = $v['user_id'];
         $userRow['name'] = $v['user_name'];
         $userRow['login'] = $v['user_login'];
         $userRow['email'] = $v['user_email'];
         $userRow['roles'] = $v['user_roles'] == null ? '' : $v['user_roles'];
         $users[$id] = $userRow;
     }
     $returnJson = array('error' => false, 'items' => $users, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #7
0
 public function loadAction()
 {
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     $searche = $_POST['filter'];
     $blogId = intval($_POST['blogid']);
     if ($dateStart = K_Date::dateParse($_POST['date-start'])) {
         $dateStart = mktime(0, 0, 0, $dateStart['m'], $dateStart['d'], $dateStart['y']);
     }
     if ($dateStop = K_Date::dateParse($_POST['date-stop'])) {
         $dateStop = mktime(23, 59, 59, $dateStop['m'], $dateStop['d'], $dateStop['y']);
     }
     if (is_numeric($_POST['price-start'])) {
         $priceStart = $_POST['price-start'];
     }
     if (is_numeric($_POST['price-stop'])) {
         $priceStop = $_POST['price-stop'];
     }
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     $where = '';
     // перечень полей из пост запроса для проверки
     $fields = array('id' => 'o.id', 'idc1' => 'o.idc1', 'type' => 'o.type', 'filial' => 'o.filial', 'adres' => 'o.adres', 'comnati' => 'o.comnati');
     $where = K_Afunc::where($fields, $_POST);
     //  var_dump($where);
     // цена объекта
     if ($priceStart && $priceStop) {
         if ($priceStart > $priceStop) {
             $where[] = "UNIX_TIMESTAMP(o.price) >= " . K_Db_Quote::quote($priceStart);
         } else {
             $where[] = "(UNIX_TIMESTAMP(o.price) BETWEEN  " . K_Db_Quote::quote($priceStart) . " AND " . K_Db_Quote::quote($priceStop) . ")";
         }
     } else {
         if ($priceStart) {
             $where[] = "UNIX_TIMESTAMP(o.price) >= " . K_Db_Quote::quote($priceStart);
         } else {
             if ($priceStop) {
                 $where[] = "UNIX_TIMESTAMP(o.price) <= " . K_Db_Quote::quote($priceStop);
             }
         }
     }
     // дата публикации объекта
     if ($dateStart && $dateStop) {
         if ($dateStart > $dateStop) {
             $where[] = "UNIX_TIMESTAMP(o.date_publication) >= " . K_Db_Quote::quote($dateStart);
         } else {
             $where[] = "(UNIX_TIMESTAMP(o.date_publication) BETWEEN  " . K_Db_Quote::quote($dateStart) . " AND " . K_Db_Quote::quote($dateStop) . ")";
         }
     } else {
         if ($dateStart) {
             $where[] = "UNIX_TIMESTAMP(o.date_publication) >= " . K_Db_Quote::quote($dateStart);
         } else {
             if ($dateStop) {
                 $where[] = "UNIX_TIMESTAMP(o.date_publication) <= " . K_Db_Quote::quote($dateStop);
             }
         }
     }
     if ($where && count($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = new K_Db_Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS o.*, b.symbol letter, t.name typename, t.color color, o.branchID filial_info, b.symbol letter, b.phone, b.address, b.email, b.title filial FROM `obj_objects` o\n                 \n                    LEFT JOIN obj_rooms r ON r.id = o.id \n                    LEFT JOIN obj_types t ON t.id = o.type \n                    LEFT JOIN obj_branches b ON b.id = o.branchID \n                    \n                {$where} ORDER BY date_publication DESC LIMIT {$start}, {$onPage}";
     $itemsRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $items = array();
     // сделать вывод планировок.
     // var_dump($itemRow);
     $this->view->objectRow = $itemRow;
     foreach ($itemsRes as $v) {
         $itemRow['id'] = $v['id'];
         $itemRow['id1c'] = $v['id1c'];
         $itemRow['type'] = $v['typename'];
         $itemRow['filial'] = strip_tags(htmlspecialchars($v['filial']));
         $itemRow['adress'] = strip_tags($v['city'] . ' ' . $v['city'] . ' ' . $v['street']);
         $itemRow['rooms'] = strip_tags(htmlentities($v['rooms']));
         $itemRow['price'] = $v['price'];
         $itemRow['color'] = strtoupper($v['color']);
         $items[] = $itemRow;
     }
     $returnJson = array('error' => false, 'items' => $items, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #8
0
 public function loadAction()
 {
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     $searche = $_POST['filter'];
     $newId = intval($_POST['newid']);
     if ($dateStart = K_Date::dateParse($_POST['date-start'])) {
         $dateStart = mktime(0, 0, 0, $dateStart['m'], $dateStart['d'], $dateStart['y']);
     }
     if ($dateStop = K_Date::dateParse($_POST['date-stop'])) {
         $dateStop = mktime(23, 59, 59, $dateStop['m'], $dateStop['d'], $dateStop['y']);
     }
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     if ($dateStart && $dateStop) {
         if ($dateStart > $dateStop) {
             $where[] = "UNIX_TIMESTAMP(comment_date) >= " . K_Db_Quote::quote($dateStart);
         } else {
             $where[] = "(UNIX_TIMESTAMP(comment_date) BETWEEN  " . K_Db_Quote::quote($dateStart) . " AND " . K_Db_Quote::quote($dateStop) . ")";
         }
     } else {
         if ($dateStart) {
             $where[] = "UNIX_TIMESTAMP(comment_date) >= " . K_Db_Quote::quote($dateStart);
         } else {
             if ($dateStop) {
                 $where[] = "UNIX_TIMESTAMP(comment_date) <= " . K_Db_Quote::quote($dateStop);
             }
         }
     }
     if ($newId) {
         $where[] = " comment_new = " . K_Db_Quote::quote($newId);
     }
     if ($searche) {
         $where[] = " (comment_name like " . K_Db_Quote::quote($searche . '%') . " OR comment_email like " . K_Db_Quote::quote($searche . '%') . ")";
     }
     if ($_POST['comments-status']) {
         $where[] = " comment_status = " . K_Db_Quote::quote($_POST['comments-status']);
     }
     if ($where && count($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = new K_Db_Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS * from comments {$where} order by comment_date DESC LIMIT {$start}, {$onPage}";
     $itemsRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $items = array();
     foreach ($itemsRes as $v) {
         $itemRow['id'] = $v['comment_id'];
         $itemRow['date'] = $v['comment_date'];
         $itemRow['name'] = strip_tags(htmlspecialchars($v['comment_name']));
         $itemRow['content'] = strip_tags(htmlspecialchars($v['comment_content']));
         $itemRow['status'] = $v['comment_status'];
         $itemRow['ip'] = long2ip($v['comment_ip']);
         $items[] = $itemRow;
     }
     $returnJson = array('error' => false, 'items' => $items, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #9
0
    /**
     * Выбирает ветку начиная с ноды  
     *
     * @param int id ноды с которой начать выборку ветки 
     * @return возвращяет ветку запрашиваемого дерева.
     * @removeRootNode убират ноду с кторой начинаеться выборка
     */
    public static function getTreeBranch($id = NULL, $removeRootNode = false, $typeFilter = false)
    {
        if ($typeFilter) {
            if (is_string($typeFilter)) {
                $typeFilter = array($typeFilter);
            }
            foreach ($typeFilter as $v) {
                $typeFilterArr[] = K_Db_Quote::quote($v);
            }
            $typeFilterWhere = "  AND tree_type IN(" . implode(',', $typeFilterArr) . ') ';
        }
        if ($id) {
            $node = self::getNode($id);
            $query = 'SELECT *
				FROM tree
				WHERE tree_lkey >= ' . (int) $node['tree_lkey'] . ' AND tree_rkey <= ' . (int) $node['tree_rkey'] . $typeFilterWhere . '
     			ORDER BY tree_lkey';
        } else {
            $query = 'SELECT *
				FROM tree
				ORDER BY tree_lkey';
        }
        $treeTable = new K_Tree_Model();
        $branch = $treeTable->fetchArray($query);
        //удаляем родительскую ноду
        if ($removeRootNode) {
            foreach ($branch as $k => &$v) {
                if ($node['tree_id'] == $v['tree_id']) {
                    unset($branch[$k]);
                }
            }
        }
        return $branch;
    }
Example #10
0
 public function loadAction()
 {
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     $searche = $_POST['filter'];
     $newId = intval($_POST['newid']);
     if ($dateStart = K_Date::dateParse($_POST['date-start'])) {
         $dateStart = mktime(0, 0, 0, $dateStart['m'], $dateStart['d'], $dateStart['y']);
     }
     if ($dateStop = K_Date::dateParse($_POST['date-stop'])) {
         $dateStop = mktime(23, 59, 59, $dateStop['m'], $dateStop['d'], $dateStop['y']);
     }
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     if ($dateStart && $dateStop) {
         if ($dateStart > $dateStop) {
             $where[] = "UNIX_TIMESTAMP(type_news_date) >= " . K_Db_Quote::quote($dateStart);
         } else {
             $where[] = "(UNIX_TIMESTAMP(type_news_date) BETWEEN  " . K_Db_Quote::quote($dateStart) . " AND " . K_Db_Quote::quote($dateStop) . ")";
         }
     } else {
         if ($dateStart) {
             $where[] = "UNIX_TIMESTAMP(type_news_date) >= " . K_Db_Quote::quote($dateStart);
         } else {
             if ($dateStop) {
                 $where[] = "UNIX_TIMESTAMP(type_news_date) <= " . K_Db_Quote::quote($dateStop);
             }
         }
     }
     if ($_POST['news-lang']) {
         $where[] = " type_news_lang = " . K_Db_Quote::quote($_POST['news-lang']);
     }
     if ($section = intval($_POST['section'])) {
         $where[] = " tree_pid = " . K_Db_Quote::quote($section);
     }
     if ($searche && mb_strlen($searche) > 2) {
         if ($searche) {
             $where[] = "(type_news_title LIKE " . K_Db_Quote::quote('%' . $searche . '%') . ' OR type_news_author LIKE ' . K_Db_Quote::quote($searche . '%') . ")";
         }
     }
     if ($where && count($where)) {
         $where = ' WHERE ' . implode(' AND ', $where);
     }
     $query = new K_Db_Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS type_news.*,type_section_ua_name from type_news\n                LEFT JOIN tree ON tree_id = type_news_id \n                LEFT JOIN type_section ON type_section_id = tree_pid \n        {$where} order by type_news_date DESC LIMIT {$start}, {$onPage}";
     $itemsRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $items = array();
     foreach ($itemsRes as $v) {
         $itemRow['id'] = $v['type_news_id'];
         $itemRow['date'] = $v['type_news_date'];
         $itemRow['title'] = strip_tags(htmlspecialchars($v['type_news_title']));
         $itemRow['lang'] = strip_tags($v['type_news_lang']);
         $itemRow['section'] = strip_tags($v['type_section_ua_name']);
         $itemRow['author'] = strip_tags(htmlentities($v['type_news_author']));
         $items[] = $itemRow;
     }
     $returnJson = array('error' => false, 'items' => $items, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #11
0
 public function loadAction()
 {
     $userModel = new Admin_Model_User();
     $page = intval($_POST['page']);
     $onPage = intval($_POST['onPage']);
     $filter = $_POST['filter'];
     if ($page) {
         if (!$onPage) {
             $onPage = 10;
         }
         $start = $page * $onPage - $onPage;
     } else {
         $start = 0;
         $page = 1;
         $onPage = 10;
     }
     $where = 'WHERE 1=1';
     if ($filter) {
         $where = "WHERE r.role_name like " . K_Db_Quote::quote($filter . '%');
     }
     $query = new K_Db_Query();
     $sql = "SELECT SQL_CALC_FOUND_ROWS r.*, p.role_name AS parent, (SELECT count(*) as rule_count FROM rule WHERE rule_role_id=r.role_id) as rule_count FROM role AS r LEFT JOIN role AS p ON r.role_status = 1 AND p.role_status = 1 AND r.role_parent_id = p.role_id  {$where}  ORDER BY r.role_level LIMIT {$start}, {$onPage}";
     //$sql = "SELECT SQL_CALC_FOUND_ROWS u.*, (SELECT GROUP_CONCAT(role_name SEPARATOR ', ') as user_roles FROM users_roles ur left join role  on ur.usrol_role_id=role_id WHERE ur.usrol_user_id = u.user_id) as user_roles FROM users u
     //  $where order by user_name LIMIT $start, $onPage";
     $rolseRes = $query->q($sql);
     $sql = "SELECT FOUND_ROWS() as countItems;";
     $countItems = $query->q($sql);
     $countItems = $countItems[0]['countItems'];
     $roles = array();
     foreach ($rolseRes as $v) {
         $id = $v['role_id'];
         $roleRow['name'] = $v['role_name'];
         $roleRow['role_acl_key'] = $v['role_acl_key'];
         $roleRow['parentid'] = $v['role_parent_id'] == null ? '' : $v['role_parent_id'];
         $roleRow['parentname'] = $v['parent'] == null ? 'Нет предка' : $v['parent'];
         $roleRow['rule_count'] = $v['rule_count'];
         $roles[$id] = $roleRow;
     }
     $returnJson = array('error' => false, 'items' => $roles, 'countItems' => $countItems);
     $this->putJSON($returnJson);
 }
Example #12
0
 /**
  * @function update - îáíàâëåíèå çàïèñè â òàáëèöå 
  * 
  * @param $data - ìàññèâ äàííûõ
  * 
  * @param $where - óñëîâèÿ ïî êîòîðûì îáíîâëÿòü çàïèñè 
  * 
  */
 public function update($data, $where = null, $setModTime = true)
 {
     $set = array();
     if (count($data)) {
         foreach ($data as $key => $value) {
             // ïðîâåðêà íà íóë, òåïåðü ìîæíî óñòàíàâëèâàòü çíà÷åíèå null â áàçó
             $v = is_null($value) ? 'null' : K_Db_Quote::quote($value);
             $set[] = K_Db_Quote::quoteKey($key) . ' = ' . $v;
         }
     }
     $whereString = '1=1';
     if (!empty($where)) {
         if ($where instanceof K_Db_Select) {
             $whereString = $where->where;
         } elseif (is_array($where)) {
             $select = K_Db_Select::create();
             $whereString = $select->_where(array($where));
         } elseif (is_string($where)) {
             $whereString = $where;
         }
     }
     $sql = 'UPDATE ' . $this->name . ' SET ' . implode(',', $set) . ' WHERE ' . $whereString;
     $this->db->query($sql);
     if ($setModTime) {
         $this->db->_setLastDataChange($this->name);
     }
 }
Example #13
0
 protected function buildJoins()
 {
     if (count($this->joins)) {
         unset($this->joinTables);
         $this->joinTables = array();
         foreach ($this->joins as &$joinInfo) {
             $sql = $joinInfo['type'] . ' join ';
             $alias = '';
             $tableName = '';
             if (is_string($joinInfo['table'])) {
                 $tableName = $joinInfo['table'];
             } elseif (is_array($joinInfo['table']) && count($joinInfo['table'])) {
                 $keys = array_keys($joinInfo['table']);
                 $alias = $keys[0];
                 $tableName = $joinInfo['table'][$alias];
             }
             $sql .= K_Db_Quote::quoteKey($tableName);
             if (!empty($joinInfo['condition'])) {
                 $sql .= ' on ';
                 $where = '';
                 if (is_string($joinInfo['condition'])) {
                     $where = '(' . $joinInfo['condition'] . ')';
                 } elseif (is_array($joinInfo['condition'])) {
                     $where = '(' . $this->_where(array($joinInfo['condition'])) . ')';
                 } else {
                     $where = '(1=1)';
                 }
                 $sql .= $where;
                 if (!empty($alias)) {
                     $sql .= ' as ' . K_Db_Quote::quote($alias);
                 }
             } else {
                 $sql = ', ' . K_Db_Quote::quoteKey($tableName);
             }
             $this->joinTables[] = array('sql' => $sql, 'type' => 'join', 'name' => $tableName);
         }
     }
 }