/** * getTableDesc * * returns the TableDesc of the model's table * * @return TableDesc */ public function getTableDesc() { return TableDesc::getTable($this->_table); }
static function singleWhere($table, $condition) { $field = array_keys($condition); $field = $field[0]; $operator = '='; if (is_array($condition[$field]) && isset($condition[$field]['operator'])) { $operator = $condition[$field]['operator']; $condition[$field] = $condition[$field][0]; } $table_desc = TableDesc::getTable($table); if (is_array($condition[$field])) { foreach ($condition[$field] as $key => $value) { settype($condition[$field][$key], $table_desc->{$field}->php_type); } $operator = 'IN'; return '`' . $table . '`.`' . $field . '` ' . $operator . ' (' . SqlTools::formatSqlValue($condition[$field]) . ')'; } settype($condition[$field], $table_desc->{$field}->php_type); return '`' . $table . '`.`' . $field . '` ' . $operator . ' ' . SqlTools::formatSqlValue($condition[$field]); }