Posts

mysql - Convert SQL query to Rails ActiveRecord query -

i have sql query multiple left joins works fine: query = <<-eos select date(t.completed_at) completed_date, s.id district, assignee_id, u.first_name, u.last_name, count(t.id) completed_tasks tasks t left join tickets k on k.id = t.ticket_id left join installations on i.id = k.installation_id left join administrative_areas on i.ward_id = a.id left join service_areas s on s.id = a.service_district_id left join users u on u.id = t.assignee_id 1 = 1 , s.id = '#{district_id}' , t.status = '#{status}' , t.kind = 1 , t.completed_at >= '#{days_ago.days.ago.beginning_of_day.to_s(:db)}' , t.completed_at <= '#{days_until.days.ago.beginning_of_day.to_s(:db)}' group date(t.completed_at), s.id, s.name, u.first_name, u.last_name, t.assignee_id eos i got value after mapping: [{:completed_date=>"2015-07-11", :district=>"1339", :assignee...

java - Can I invoke some method from XML mapping file in Hibernate? -

i have xml mapping file. can invoke method it? idea: <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="pkg.someitem" table="item"> <id name="itemid" column="itemid" unsaved-value="0"> <generator class="increment"/> </id> <property name="filesize" invoke="myfilemanager.getactualfilesize(itemid);"/> </class> </hibernate-mapping> use reflection : // xml parsing code incorrect; illustration purposes string classname = xml.getelement("class").getattribute("name").getvalue(); string methodname = xml.getattribute("invoke").getvalue(); // generic insta...

ios - How can I process multiple links of JSON data? -

the code works perfectly. problem that, after trying while, cannot figure out how make program process second link of different json data. here viewdidload goes on: override func viewdidload() { super.viewdidload() var err: nserror? let urlpath: string = "https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/" + searchfielddatapassed + "?api_key=(removed private api key obvious reasons" var url: nsurl = nsurl(string: urlpath)! let session = nsurlsession.sharedsession() let task = session.datataskwithurl(url) { data, response, error in // cast response nshttpurlresponse , switch on statuscode if if let httpresponse = response as? nshttpurlresponse { switch httpresponse.statuscode { case 200..<300: println("ok") default: println("not ok") } } // parse json using nsjsonserialization if you've got data if let jsonresult = nsjsonserializatio...

php - pulling mysql data for timelinejs? -

i'm trying pull data mysql database create json file use timelinejs timeline. problem json file must formatted way. i've created following code formats json correctly, pulling 1 entry database (specifically last entry). guys offer appreciated! <?php $link = mysql_pconnect("localhost", "root", "********") or die("could not connect"); mysql_select_db("php_test") or die("could not select database"); $rs = mysql_query("select * timelinetest"); while($row = mysql_fetch_array($rs, mysql_assoc)) $object = array ('timeline'=> array( 'headline'=>'georgia history title page', 'type'=>'default', 'text'=> 'testing overview', 'startdate'=>'1700', 'asset'=>array('media'=>'titlepagemedia', 'credit'=>'titlepagecredit', ...

c# - WCF certificate authentication -

while implementiong wcf security using certificate, facing below mentioned error. secure channel cannot opened because security negotiation remote endpoint has failed. may due absent or incorrectly specified endpointidentity in endpointaddress used create channel. i have put certificates in trusted people. it looks identity problem , have tried setting identity both in service , client config still didn't work. below configuration details. service configuration <bindings> <wshttpbinding> <binding name="wshttp"> <security mode="message"> <message clientcredentialtype="certificate" /> </security> </binding> </wshttpbinding> </bindings> <service name="wcfcertificateauth.service1"> <endpoint address="" binding="wshttpbinding" bindingconfiguration="" bindingn...

php - How to get user id in session? -

kinda noob problem i'm working on 2 hours , can't solve i have login system works fine (thanks tutorials), i'd save id in session when user's logging this login.php: <?php session_start(); require_once 'config.php'; if(isset($_post['btn-login'])){ $uname = $_post['txt_uname_email']; $umail = $_post['txt_uname_email']; $upass = $_post['txt_password']; $sth = $bdd->prepare("select user_id users user_name=$uname"); $sth->execute(); $result = $sth->fetch(pdo::fetch_assoc); $uid = $result; if($user->login($uname,$umail,$upass)){ $_session['user_name'] = $uname; $_session['user_mail'] = $umail; $_session['user_session'] = $userrow['user_id']; $_session['user_id'] = $uid; $uname = $_post['txt_uname_email']; $umail = $_post['txt_uname_email']; $upass = $_p...

Best way to render two dimensional table in grails -

i need table displayed , headings, have 2 lists: list1 = [a, b, c, d, e, f, g] and list2 list of maps list2 = [ [from: a, to: a, val:20], [from: a, to: b, val:10], [from: a, to: c, val:30], [from: b, to: a, val:10], [from: b, to: b, val:40] ] the result should be from b c d e f g 20 10 30 - - - - b 10 40 - - - - - c - - - - - - - d - - - - - - - e - - - - - - - f - - - - - - - g - - - - - - - how can that? <table> <tr> <th>from</th> <th>to</th> <g:each in="${list1}" var="item"> <th>${item}</th> </g:each> </tr> <g:each in="${list1}" var="fromitem"> <tr> <td>${fromitem}</td> <td></td> <g:each in="${list1}" var...