Posts

mysqli - php using prepared statement within foreach loop -

according example prepared statements first bind parameters , set values parameters. let's assume have 2-dim array $alias $array1 = [ 'id' => 1, 'tstamp' => 123456789, 'alias' => '$alias', ]; $array2 = [ 'id' => 1, 'tstamp' => 123456789, 'alias' => '$alias2', ]; $alias = [$array1, $array2]; why code working $insert = 'insert abcdef values (?,?,?)'; $insertstmt = $conn->prepare($insert); foreach ($alias $array) { $insertstmt->bind_param('iis', $array['id'], $array['tstamp'], $array['alias']); $insertstmt->execute(); } and not? $insert = 'insert abcdef values (?,?,?)'; $insertstmt = $conn->prepare($insert); $insertstmt->bind_param('iis', $array['id'], $array['tstamp'], $array['alias']); foreach ($alias $array) { $insertstmt->execute(); } if have bind...

php - How to validate phone number in laravel 5.2? -

i want validate user input phone number number should 11 , started 01 , value field should number only. how do using laravel validation? here controller: public function saveuser(request $request){ $this->validate($request,[ 'name' => 'required|max:120', 'email' => 'required|email|unique:users', 'phone' => 'required|min:11|numeric', 'course_id'=>'required' ]); $user = new user(); $user->name= $request->input(['name']); $user->email= $request->input(['email']); $user->phone= $request->input(['phone']); $user->date = date('y-m-d'); $user->completed_status = '0'; $user->course_id=$request->input(['course_id']); $user->save(); return redirect('success'); } one ...

Is there a better way to make this mysql query using inner join commands? -

in database have several tables "many many" relationships referencing 1 another, , way taught make queries through embedded queries. i've been reading "many many" relationships, , how query them using "inner join" but, don't seem able find queries fit i'm looking for, , since database work big tables don't want code have performance issues. select salones.idsalon, salones.lat, salones.long, recursos.idrecurso, recursos.recurso salones, recursos, salones_has_recursos salones_has_recursos.salones_idsalon=salones.idsalon , salones_has_recursos.recursos_idrecurso=recursos.idrecurso , recursos.idrecurso in (select idrecurso salones_has_recursos idrecurso in (select idrecurso recursos recurso = 'audiovisual' ...

Eclipse indexing - what do the various options do -

when right-click > index on project there few options: rebuild freshen files update modified files re-resolve unresolved includes i've been hitting rebuild everytime i'm working on huge project , can't afford that; when modify file, whether it's .cpp or .h, need know 'index' operation do. for each of 'index' options: what precisely do? what cost (relative memory, cpu time)? documentation eclipse helpful searched , didn't find any.

c++ - Qt GUI doesn't work with std::thread as I expect -

the core of project independent of gui framework that's why prefer std::thread. qt gives me error when thread using. the inferior stopped because received signal operating system. signal name: sigsegv signal meaning: segmentation fault //mainwindow.h #ifndef mainwindow_h #define mainwindow_h #include <thread> #include <mutex> #include <qmainwindow> namespace ui { class mainwindow; } struct observer { virtual void notify() = 0; }; class core { public: std::thread *run() { std::thread thread(&core::runp, this); thread.detach(); return &thread; } void setobserver(observer *observer) { _observer = observer; } int ii() const { return _ii; } void nextii() { _ii++; } void lock() { _mutex.lock(); } bool trylock() { return _mutex.try_lock(); } void unlock() { _mutex.unlock(); } private: void runp() { (int = 1; <= 1000; i++)...

java - How to output files with a specific extension (like .csv) in Hadoop, using MultipleOutputs class -

i have mapreduce program uses multipleoutputs to output result multiple files. reducer looks this: private multipleoutputs mo = new multipleoutputs<nullwritable, text>(context); ... public void reduce(edge keys, iterable<nullwritable> values, context context) throws ioexception, interruptedexception { string date = records.formatdate(millis); out.set(keys.get(0) + "\t" + keys.get(1)); parser.parse(key); string filepath = string.format("%s/part", parser.getfileid()); mo.write(noval, out, filepath); } this similar example in book hadoop: definitive guide - however, problem outputs files plain text. want files outputted .csv files , haven't managed find explanation on in book or online. how can done? have tried iterate through output folder after completion of job object in driver rename files? as long emit in reducer (the text should line in csv values separated semicolon o...

Clone TFS-GIT repository to GIT repository (Linux) by using GIT -

we have redhat linux server, git installed on server , need create local repository. we have tfs-git project in tfs 2015, need clone tfs-git repository git repository on linux using git commands. for task, created empty local repository on linux, , configured basic authentication , configured ssl certification using server manager. still getting "fatal: authentication error" connecting tfs-git repository on windows server 2012 . tried in different ways still getting same error. am using basic credentials used server logins , have id , password everything. is there specific kind of passsord need use this? please advise me on this thanks in advance you have done should be. need copy public key of desired user unix server work. how setup ssh-key? # generate key (local machine) ssh-keygen -t rsa # copy generated key unix machine (server) # key in : %home%/.ssh/id_rsa.pub # in widows under user account: users/<user_name> other ways if ...