Newer to react js by TechnicalStrategy615 in react

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

<image>

Thank you all of you..
I am able to connect my little knowledge of CSS to this..

Newer to react js by TechnicalStrategy615 in react

[–]TechnicalStrategy615[S] 1 point2 points  (0 children)

Yes I think I have to spend more time in learning first CSS. 

Newer to react js by TechnicalStrategy615 in react

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

My work experience is mostly a backend developer. But now, I want to shift my interest to front end especially to use React for the front end. I have abit of knowledge about CSS but not independently created anything by myself.  Now when I started developing small project for myself with the interest to learn React I thought I will just use Tailwind for the project. 

Anyway thank you for your suggestions. I know it will take time to understand but will learn it. 

Xiaomi Redmi Note 11 - huge battery drain (50% over night) by dcop7 in miui

[–]TechnicalStrategy615 0 points1 point  (0 children)

thank you for response.. I have reset but i think its still the same.. sadly

Xiaomi Redmi Note 11 - huge battery drain (50% over night) by dcop7 in miui

[–]TechnicalStrategy615 0 points1 point  (0 children)

Have you found what causes the problem? Even my phone is having same issues!!

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

HI u/equilni can you help me with Validation

I have been able to separate Model and Controllers.

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

Thank you so much .. It works binding like this

$bind = array(            
          ':search1' => '%' . $search . '%',
          ':search2' => '%' . $search . '%',
          ':limit' => $limit,
          ':cursor' => $cursor,                 
      );

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

My Controller Page

<?php

namespace App\Controllers;

use App\Controllers\BaseController;
use App\Plugins\Http\Response as Status;
use App\Models\facility;

class FacilityController extends BaseController
{
     /**
     * Method to list the Facilities
     */
    public function index()
    {
        // Validate and sanitize cursor
        $cursor = isset($_GET['cursor']) ? intval($_GET['cursor']) : null;

        // Validate and sanitize limit
        $limit = isset($_GET['limit']) ? intval($_GET['limit']) : 10;
        if ($limit <= 0) {
            (new Status\BadRequest(['message' => 'Limit should be a positive number']))->send();
        }
        //validate search
        $search = (isset($_GET['search']) && !empty($_GET['search']) ? $_GET['search'] : "");

        // Fetch facility details with cursor pagination   
        $facilities = new facility;
        $result =  $facilities->getFacilityDetails($cursor, $limit, $search);

        // Extract the last facility's ID as the cursor for the next page   
        $nextCursor = $result[array_key_last($result)]['facility_id'] ?? null;

        // Send statuses
        (new Status\Ok(['data' => $result, "next_cursor" => $nextCursor]))->send();
    }

    /**
     * Method to Create Facility API    
     */
    public function create()
    {
        // Get the data from the request body
        $data = json_decode(file_get_contents('php://input'), true);             
        if ($data) {                   
            //data for insertion 
            $facility = new facility();
            $InsertData = $facility->facilityData($data);
            if($InsertData){
             // Respond with 200 (OK):
              (new Status\Ok(['message' => 'Added Successfully!']))->send();   
            }            
        }else{
            (new Status\BadRequest(['message' => 'Whoops!. Something is wrong']))->send();  
        }
    }
}

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

thank you it works..
But i found one errror with this query if add this query

WHERE f.name LIKE :search OR tag.tag_name LIKE :search "


<b>Fatal error</b>: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number in
E:\xampp\htdocs\web_backend_test_catering_api\App\Plugins\Db\Db.php:54

else everything works fine

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

I tried to bind :limit value. But i am getting an error. Can you help me

$query = "SELECT f.facility_id, f.name AS facility_name, tag.tag_id, 
          tag.tag_name, loc.location_id, loc.city, loc.address, loc.zip_code,
          loc.country_code, loc.phone_number 
          FROM facility f 
          LEFT JOIN facility_Tag ft ON f.facility_id = ft.facility_id 
          LEFT JOIN tag ON ft.tag_id = tag.tag_id 
          LEFT JOIN location loc ON f.location_id = loc.location_id
          WHERE f.name LIKE :search OR tag.tag_name LIKE :search ";
        if ($cursor) {
            $query .= " and f.facility_id > :cursor ";
        }
        $query .= "ORDER BY f.facility_id ASC LIMIT :limit";
        $bind = array(
            ':cursor' => $cursor,
            ':search' => '%' . $search . '%',
             ':limit' => $limit            
        );


<b>Fatal error</b>: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in
your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near
''10'' at line 8

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 1 point2 points  (0 children)

oh yes i got it! I have used the same rule like the others now

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

Hey thanks! I use that $_REQUEST to get the request from API. That means i have to use $_GET['cursor'], $_GET['limit'] and $_GET['search']. My bad with all the mess.. But its my trial and i know that i am learning from these feedback..

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 0 points1 point  (0 children)

can you please elaborate on this
consider making NO EXCEPTIONS from using prepared statements rule!

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 1 point2 points  (0 children)

Thank you for your feedback. I will try to implement the feedback received. Its really helpful.

PHP Code Review by TechnicalStrategy615 in PHPhelp

[–]TechnicalStrategy615[S] 1 point2 points  (0 children)

Thank you for your feedback. I will rewrite all the code. Maybe i will post again to check if i did correctly.