Posts

php - How to convert xls to mysql? -

how convert large xls or csv dataset mysql data using php , preferably using silverstripe api? can directly or need convert first text? silverstripe has number of ways import csv files datamodel. the documentation worth reading on section: https://docs.silverstripe.org/en/3.1/developer_guides/integration/csv_import/ the quickest , simplest way manage custom dataobject modeladmin interface , use built in csv importer. class playeradmin extends modeladmin { private static $managed_models = array( 'player' ); private static $url_segment = 'players'; } when go player modeladmin see csv import form on left. make sure column titles in csv file line variable names of data object. for more complex import methods read documentation alternative methods allow so.

R: pass variable from R to unix -

i running r script via bash script , want return output of r script bash script keep working there. the bash sth this: #!/bin/bash rscript myrscript.r a=output_from_myrscript.r sth and r script sth this: for(i in 1:5){ sink(type="message") } i want bash work 1 variable r @ time, meaning: bash receives i=1 , works that, when task done, receives i=2 , on. any ideas how that? one option make r script executable #!/usr/bin/env rscript (setting executable bit; e.g. chmod 0755 myrscript.r , chmod +x myrscript.r , etc...), , treat other command, e.g. assigning results array variable below: myrscript.r #!/usr/bin/env rscript cat(1:5, sep = "\n") mybashscript.sh #!/bin/bash res=($(./myrscript.r)) elem in "${res[@]}" echo elem "${elem}" done nrussell$ ./mybashscript.sh elem 1 elem 2 elem 3 elem 4 elem 5

php - PDO lastInsertId() -

i'm using pdo on mysql database , try retrive lastinsertid() . i thought going last inserted vlue in column id in table primary_key . however, 0 output $statement = "select last_insert_id() my_table"; $sql = $dbh->query($statement); $lastid = $sql->fetch(pdo::fetch_num); $lastid = $lastid[0]; return $lastid; pdo class has method called lastinsertid() . can use method after inserting record/records collect last insert id.

What's wrong with this Java Linked List representation of a stack of integers? -

okay, following code nullpointer exception in pop method. therefore, know 'head' must null when method runs. thing have no idea why , i've looked on code bit now. please help! here is: node class: public class stacknode{ private stacknode link; //link next node private int value; public stacknode(int value, stacknode linkvalue){ this.link = link; this.value = value; } public stacknode(){ this.link = null; } public void setnodedata(int value){ this.value = value; } public void setlink(stacknode newlink){ this.link = newlink; } public int getvalue(){ return this.value; } public stacknode getlink(){ return link; } } linked list class: public class intstacklist{ private stacknode head; public intstacklist(){ this.head = null; } public void push(int value){ this.head = new stacknode(value, head); } public int pop(){ int value = this.head.getvalue(); //get int value stored in head node this.hea...

php - Configuring urlManager Rules in Yii2 -

i'm new using yii2 , have been using urlmanager, have following code, works fine think should shorter. have couple rules follows :- 'rules' => [ 'gifts/<subjectone:[\s\s]+>/<subjecttwo:[\s\s]+>' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>/<subjecttwo:[\s\s]+>/' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>/' => 'gifts/index', ]; as can see i've added 4 rules go same page handle different situations. i've had add same url's twice, once / , 1 without stop 404's. please advise of better way handle this. you can add +|(\/?) @ trailing of rule. take look: 'gifts/<subjectone:[\s\s]+>+|(\/?)' => 'gifts/index', so there no need write rules twice.

mysql - select query for minus one hour -

Image
have below query: select hr, red (select hour(event_datetime) hr, max(red_kills) - (select max(red_kills) vwmatchall date_format(event_datetime,"%y-%m-%d %h") = date_format(date_sub(event_datetime, interval 1 hour), "%y-%m-%d")) red vwmatchall date(event_datetime) = '2015-10-09' group hour(event_datetime)) k the data structured such: the idea take current max() value of given column, red_kills in above example, , subtract max() value of same column, 1 hour previous. it's show difference hour. if 1 date doesn't have data 24 hours, still show data hours have. idea what's wrong query?

Skype chat window is not opening by using Skype Id of user after login in android -

i implementing skype integration in android application. have requirement open chat window of skype using skype id of user. have done successfully, problem when logged out skype , open the skype android application using user id redirecting login screen , after login same user id, skype application goes in background , redirect android application. want open chat window of skype when logged in id opening chat window. please suggest me, how can implement ? can show code using show skype intent? it should similar : intent skypeintent = new intent("android.intent.action.view"); skypeintent.setdata(uri.parse("skype:" + user_name)); startactivity(skypeintent); in manifest need following intent filter : <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <data android:scheme="skype" /> </intent-filter> ...