Posts

php - Get data except for data in a column -

so have following code: require_once('db.php'); $getusers = mysqli_query($db, 'select * users'); $rows = []; while ($r = mysqli_fetch_assoc($getusers)) { $rows[] = $r; $getskills = mysqli_query($db, "select * skills id = '" . $r['id'] . "'"); while($r = mysqli_fetch_assoc($getskills)) { $rows['skills'] = $r; } } print(json_encode($rows)); which outputs: [{"id":"1","name":"user1","skills":{"woodcutting":"6","mining":"10"}},{"id":"2","name":user2"}] there 2 problems: i'd of data in table skills except id, or at-least cut off before encoding json. for reason can't "skills" shown after first user. user2 should have skills object. what doing wrong? to columns except id table skills , can either list columns want select, this: mysqli...

mysql - SQL Querying: How to Find the Maxima of Certain Columns within Different Sets of Similar Records? -

how find secret ingredients used in pizzas have won prize? i’m missing sql condition in comment below: select r.name, p.secret_ingredient restaurants r join restaurant_has_pizzas rhp on rhp.restaurant_id = r.id join pizzas p on p.id = rhp.pizza_id join awarded_prizes on a.id = r.latest_prize_id r.owner = 'me!' , p.created_at < a.won_at -- , p young/new possible, i.e., p.created_at close -- a.won_at possible; i’m interested in winning pizzas -- have been made right before taster awarded prize! ; the query far returns kinds of ingredients used in restaurants have won prize. however, i’m interested in those secret ingredients used in winning pizzas. note chefs have created newer pizzas since have won last prizes. here’s ddl: create table pizzas (`id` int not null auto_increment, `created_at` datetime not null, `secret_ingredient` varchar(42) not null, primary key (`id`)) ; insert pizzas (`created_at`, `secret_ingredient`) value...

linux - PHP forked process not exit completely and become zombie -

this question has answer here: php forking issue 2 answers this simplified program. the test.php daemon program, running there. forks process work on task. once finishing work, forked process exits. when forked process exits, becomes zombie. how make forked process exit without becoming zombie? #!/usr/bin/php <?php while (1) { sleep(1); $pid = pcntl_fork(); if (!$pid) { $mypid = getmypid(); sleep(5); print "pid=$mypid finish work \n"; exit(); } sleep(1); } // while ?> ./test.php ... daemon running ... $ ps -ef | grep mqp ubuntu 10084 10073 0 12:21 pts/0 00:00:00 /usr/bin/php ./test.php ubuntu 10085 10073 0 12:21 pts/0 00:00:00 /usr/bin/php ./test.php ubuntu 10074 10073 0 12:21 pts/0 00:00:00 [test.php] <defunct> ubuntu 10075 10073 0 12:21 pts/0 00:00:00 [test.php] <defunct> ...

javascript - How does ServiceNameQuery work in AngularJS -

for example, there following piece of code: $scope.posts = post.query({ user_id: $stateparams.user_id }) how construction work? when js execute line posts may empty, after time server side return posts , view render lot of posts. how 'query' function may return value in future? don't understand it, because ajax call asynchronous, , don't send value in function. please, describe moment. thanks. i know promises , $q, don't understand how works here. internally executes asynchrnous operation , returns reference empty array. when asynchronous operation has finished populate array elements. $scope.posts reference same array, containing elements. simple example implementation: app.factory('post', function ($timeout) { var query = function (selector) { var result = []; // asynchronous operation $timeout(function () { (var = 0; < 5; i++) { result.push({ id: }); } }, 3000); return result; ...

c# - Custom Authorize Attribute and Entity Framework -

i implementing action/activity based authorization in asp.net application. trying make reusable library can use other projects. using entity framework data access. i able implement functionality not sure how configure entity framework connection string authorize attribute. custom authorize attribute: public class authorizeaction: authorizeattribute { private string _actions; private string[] _actionssplit = new string[0]; public string actions { { return _actions ?? string.empty; } set { _actions = value; _actionssplit = value.split(','); } } protected override bool authorizecore(system.web.httpcontextbase httpcontext) { string userid = string.empty; if (httpcontext == null) { throw new argumentnullexception("httpcontext"); } iprincipal user = httpcontext.user; if(!user.identity.isauthenticated) { ...

php - preg_match Regex Matching Full String -

i have simple regex, it's matching more want... basically, i'm trying match operators (eg. > < != = ) followed string. regex: /^(<=|>=|<>|!=|=|<|>)(.*)/ example subject: >42 what i'm getting: array (size=3) 0 => string '>42' (length=3) 1 => string '>' (length=1) 2 => string '42' (length=2) what i'm trying get: array (size=2) 0 => string '>' (length=1) 1 => string '42' (length=2) what don't understand regex works on regex101 edit: clarify, how can rid of full string match? your answer correct. group(0) whole match . group(1) if first group , group(2) second group.

c++ - Fill function in basic graphics app in Qt -

i have been creating basic graphics program(like ms paint) simple gui. have 2 classes 1 mainwindow holds buttons, sliders etc , second class custom widget called drawingarea on user able draw. basicly i've implemented of functions, unfortunetly stucked @ filling function, should work 1 in ms paint. decided use called floodfill algorithm , after few hours of fighting(i beginner in qt) have managed make work. not @ all. problem able fill black-colored regions(shapes, lines, points etc) color choose. when comes filling different colors, puts 1 pixel in chosen color. in funcion fill(...) below passing 2 arguments - point(mouseclicked) , color of point. here: void drawingarea::fill(const qpoint &point, qcolor act) { qpainter painter(&image); qpen mypen(actualcolor); mypen.setwidth(1); painter.setpen(mypen); qqueue<qpoint> pixels; pixels.enqueue(point); while(pixels.isempty() == 0) { qpoint newpoint = pixels.dequeue(); qcolor actual; actual.fromrgb(imag...