Search Posts

Month: December 2017

Group By date Doctrine

I have this query SELECT DATE_FORMAT(exp_date, “%Y-%m”) AS Month, sum(exp_total) FROM export GROUP BY DATE_FORMAT(exp_date, “%Y-%m”); I tried to convert it to symfony doctrine: $qb = $this ->createQueryBuilder(‘e’) ->select(‘DATE_FORMAT(e.expDate, ‘%Y-%m’), sum(e.expTotal) total’) ->groupBy(‘DATE_FORMAT(e.expDate, ‘%Y-%m’)’); return $qb->getQuery()->getResult(); Using: “beberlei/DoctrineExtensions”: “^1.0” Error: [Semantical Error] line 0, col 103 near ‘DATE_FORMAT(e.expDate,’: Error: Cannot group by undefined identification or result variable. Source: Stackoverflow

Grails 3.3.2 domain classes inheritance issue

I’ve been migrating from Grails 3.2.11 to 3.3.2 and faced an odd issue: If domain class inherits from a class from src/main/groovy – it’s created and saved into DB properly at a first time. But when you retrieve it from DB and try to update the inherited properties – they are not saved back to DB. Ex: abstract class AbstractTest { String field } class Test extends AbstractTest { static constraints = { } } […]

Can’t parse integer in mysql prepared statement using util.format() in node js

I am using util module in node.js for formatting strings. But I found a catch when I wanna run an SQL Query like – select * from something LIMIT 5 OFFSET 0; So what I am trying to do is, I’ve created a queryString then format that queryString and finally execute the query through server application. Here is the code in nodejs : queryString = “select * from something LIMIT ‘%d’ OFFSET ‘%d'”; query = […]

How to refresh vaadin table after altering data?

I have this vaadin table which i’m using to display and update records that are being stored in MySQL DB, it all works fine except for updating the table after making a modification or an update, I tried using Table.refreshRowCache() but that wasn’t useful try{ Class.forName(“com.mysql.jdbc.Driver”); Core.con = DriverManager.getConnection(Core.db,Core.dbUsername,Core.dbPassword); java.sql.Statement st = Core.con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs = st.executeQuery(Core.Show); while(rs.next()){ table.addItem(new Object[]{rs.getInt(1), rs.getString(2), rs.getDate(3)},rs.getInt(1)); } }catch(Exception e){ e.printStackTrace(); } table.addItemClickListener(new ItemClickEvent.ItemClickListener(){ @Override public void itemClick(ItemClickEvent event) { […]

Mysql: Negative balance query

I have a table called customer_wallet with id as primary key, balance(contains both -ve & +ve values), date(transaction date). Now some customers have privilege that they can do transactions in even if they have no balance. We get total Balance of a customer by doing (SUM(balance) where customer_id=xxx). I want to find out the date when customers balance comes to -ve(like 3 days ago or 5 days ago) only if current balance is in negative. […]

sql not inserting into database

I know this is a pretty common question, but I am just looking for help in identifying what’s wrong with my code. I’m attempting to create my database so that an admin can create new campsites with pictures from a form. My website seems to be working alright and when I test it, it gives me the fail message if values are not filled in and success message if required values are not filled in, […]

How to convert my table from latin1_swedish_ci to utf8 [duplicate]

This question already has an answer here: How to convert an entire MySQL database characterset and collation to UTF-8? 15 answers So, yesterday I just run 2 little mysql statements and changed the table engin and charset to InnoDB and utf-8. But after that, my php script just stopped working. Today I could sucessfully repair everything, but I don’t want to do that again because it costed me a lot of time and today is […]

Automatically show 0 sales for the date which is not in database

Im creating a graph using Chart.js. I’ve some dates and sales stored in the database. Here I’m picking the records from the DB using an ajax request and creating a bar graph using that data by dividing the data in two different arrays date[“2017-12-18″,”2017-12-20″,”2017-12-26”] and amt[“2000″,”3000″,”6000”]: $(document).ready(function(){ $.post(“ajax-req-handler.php”, { key: “draw-line-chart” }, function( data ){ console.log(data); data = JSON.parse(data); var date = []; var amt = []; for(var i in data){ date.push(data[i].sale_date); amt.push(data[i].total); } console.log(date); […]

High CPU /usr/sbin/mysqld

I realised that the /usr/sbin/mysqld process is using 70-80% of CPU. It was under 5-10% before. I already checked the MYSQL processes, but I don’t see any major query. There is one query (SELECT) which takes 4 seconds. How can I find out, what causes this high CPU and how can I make it lower? Server Information: – Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (8 cores, 8192 KB Cache) – 32GB RAM – CentOS […]

Next Page »