Category : mysqli

Here’s my json: [ { "ID": 1, "SOURCEID": 1, "TIMESTAMP": "2020-04-05 07:05:29", "VALUE": "30" }, { "ID": 4, "SOURCEID": 2, "TIMESTAMP": "2020-04-05 07:05:17", "VALUE": "40" }, { "ID": 3, "SOURCEID": 1, "TIMESTAMP": "2020-04-06 12:04:59", "VALUE": "35" }, { "ID": 5, "SOURCEID": 1, "TIMESTAMP": "2020-06-17 12:01:32", "VALUE": "1" }, { "ID": 6, "SOURCEID": 2, "TIMESTAMP": "2021-06-17 ..

Read more

I have written this code, yet I don’t know how to update the database after I perform a transaction, based on the product I purchase. Here is the MySQLi, where I think the problem is: <?php $total = $total + ($product[‘quantity’] * $product[‘price’]); mysqli_query($db, "UPDATE product set quantity = quantity-".$product[‘quantity’]." WHERE PRODUCT_ID = ‘".$product[‘id’]."’"); //$db::table(‘product’)->decrement(‘quantity’); ..

Read more

Just setting up laravel 8. In the cmd, it’s showing this warning again and again. Laravel is installed and working perfectly but my question is that is this going to be a problem? do I have to install it again? PHP Warning: PHP Startup: Unable to load dynamic library ‘/path/to/extension/mysqli.so’ (tried: /path/to/extension/mysqli.so (The specified module ..

Read more

comments table comments table stars table stars table i write this query: (for ordering sites by most stars_sum) $comments->join(‘stars’, ‘comments.star_id’, ‘=’, ‘stars.id’); $comments->selectRaw(‘comments.site_id as site_id, comments.id as comment_id, stars.key1 + stars.key2 + stars.key3 + stars.key4 + stars.key5 as stars_sum’); $comments->groupByRaw(‘site_id, comment_id DESC’); select comments.site_id as site_id, comments.id as comment_id, stars.key1 + stars.key2 + stars.key3 + ..

Read more

comments table comments table stars table stars table i write this query: (for ordering sites by most stars_sum) $comments->join(‘stars’, ‘comments.star_id’, ‘=’, ‘stars.id’); $comments->selectRaw(‘comments.site_id as site_id, comments.id as comment_id, stars.key1 + stars.key2 + stars.key3 + stars.key4 + stars.key5 as stars_sum’); $comments->groupByRaw(‘site_id, comment_id DESC’); select comments.site_id as site_id, comments.id as comment_id, stars.key1 + stars.key2 + stars.key3 + ..

Read more

I am facing an integrity constraints issue when adding a new row to a table has relation with another table (children and visits tables) every child has many visits. SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (vaccine.visits, CONSTRAINT visits_ch_id_foreign FOREIGN KEY (ch_id) REFERENCES childern (id)) ..

Read more

I have model and I am fetching records from that model I want to give admin a view where he can set request timeout for fetching data from that model? but I don’t know what to write in controller? > foreach ($grab_xmlfeed as $feed) { > $Keyword = str_replace("[KEYWORD]",$keyword,$feed->xml_url); > $Ip = str_replace("[IP]",$ip,$Keyword); > $Ua ..

Read more

I have two tables as customers and transactions. In transaction all the transaction related to customer gets stored. Now i want all the data from customers table and only sum of ‘received amount’as received from transactions table. Below is query $customers = DB::table(‘customers’) ->join(‘transactions’, ‘customers.id’, ‘=’, ‘transactions.custId’) ->where(‘customers.status’, ‘Active’) ->select(‘customers.id’, ‘customers.custName’, ‘transactions.custTotalReceived as Received’) ->paginate(100); ..

Read more

I have a problem with the image update feature on vue js using axios. this is the template code section <template> <q-page-container> <transition enter-active-class="animated fadeInLeft" leave-active-class="animated fadeOutRight" appear :duration="700" > <q-page> <q-toolbar elevated class="text-primary"> <q-btn flat round dense icon="arrow_back" @click="$router.push(‘/produk’)" /> <q-toolbar-title> Edit produk </q-toolbar-title> </q-toolbar> <form> <div class="row justify-center"> <p style=" width:90%; margin-top:10px;">Nama barang ..

Read more

I just installed Laravel on my local Mac after installing ddev, Docker and MAMP. I used https://ddev.readthedocs.io/en/stable/users/cli-usage/#laravel-quickstart guide and everything looked ok. However, when I tried to run a sample code downloaded from the Internet, I started getting the error message Illuminate Database QueryException (2002) SQLSTATE[HY000] [2002] No such file or directory (SQL: select * ..

Read more

This is table relation $result = Event::select(‘events.*’, ‘events.at as datatime’, ‘events.end_time as endtime’,’event_types.name as event_type_name’) ->from(‘events’) ->leftJoin(‘event_types’, ‘event_types.id’, ‘events.type_id’) ->where(‘events.id’, $id) ->where(‘events.user_id’, 350) ->get() ->toArray(); return $result; i want to change it to eloquent relation. for example, i think we can use with() method instead of select method of query. Sourc..

Read more

I am going to make eloquent model as belongsTo, hasManythorugh.. from some tables. i can make it when there are 3 tables but am not sure if there are 3+ tables. this is code. ->from(array(‘cases’,’c’)) ->join(array(‘case_contact’,’cc’), ‘LEFT’)->on(‘cc.case_id’, ‘=’, ‘c.id’) ->join(array(‘case_statuses’,’cs’), ‘LEFT’)->on(‘cs.case_id’, ‘=’, ‘c.id’) ->join(array(‘statuses’,’s’), ‘LEFT’)->on(‘s.id’, ‘=’, ‘cs.status_id’) ->join(array(‘milestones’,’m’), ‘LEFT’)->on(‘m.id’, ‘=’, ‘s.milestone_id’) ->join(array(‘companies’,’com’), ‘LEFT’)->on(‘com.id’, ‘=’, ‘c.company_id’) ..

Read more

I got this error ‘Fatal error: Uncaught Error: Class ‘UserController’ not found in /home/dlotjryh/public_html/dashboard/login.php:4 Stack trace: #0 {main} thrown in /home/dlotjryh/public_html/dashboard/login.php on line 4 ‘ just when i upload my file, the page we working fine on my localhost, I checked the php verion, they are both 7.2 <?php include_once ‘classLoader.php’; ?> <?php $userC = ..

Read more

I am getting very strange issue when I am trying to delete record from a table using below query: delete from `user_join_groups` where `group_id` = 1 and `user_id` = 217; Below is the error that Mysql is throwing: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘test.user_id’ doesn’t exist (SQL: delete from `user_join_groups` where ..

Read more

i have tried this to get records matching value 1 in products_applicable column Coupon::whereJsonContains(‘products_applicable’,[‘1′])->get(); how do we get records using dynamic value like $value instead of [‘1’], i have tried this Coupon::whereJsonContains(‘products_applicable’,[$value])->get(); and Coupon::whereJsonContains(‘products_applicable’,$value)->get(); also I want to merge this 2 codes like i want all records having null value at products_applicable and having $value ..

Read more

I make a Nested loop which i create a view for show my data. how can i show data of single query in view. This is my View page @foreach($products1 as $item1) <!– first product loop –> <tr> <td>{{++$i}}</td> <td>{{$item1->productname}}</td> @foreach($products2 as $item2) <!– second product loop –> @if($item1->id == $item2->id) <!– campare with second ..

Read more

#data from Api after request array:1 [▼ "id" => 1 "name" => "test" "active_domain" => "https://drycleaner.com" "domains" => array:1 [▶] "created_at" => "2020-11-03T13:10:02.000+08:00" "dr" => array:2 [▼ 0 => array:1 [▼ 0 => array:1 [▼ "end_at" => "2020-11-08T08:00:00.000+08:00" ] ] 1 => array:1 [▼ 0 => array:1 [▼ "end_at" => "2020-11-08T08:00:00.000+08:00" ] ] ] ] ..

Read more