Category : postgresql

<?php namespace AppHttpControllers; use IlluminateHttpRequest; use DB; use AppModelsUser; use AppHttpRequests; use IlluminateSupportFacadesAuth; use AppHttpControllersController; use Redirect; class Insertlikes extends Controller { public function insertlikesform() { return view(‘dashboard’); } public function insertlike(Request $request) { $book_id = $request->input(‘book_id’); $user_id = Auth::user()->id; $user_name = Auth::user()->name; if(DB::select("select count(*) from likesrate where user_id=’$user_id’ and book_id=’$book_id’")==0) { DB::insert(‘insert into likesrate ..

Read more

i have the next query with two subequery how can convert it to eloquent, i have some troubles with eloquent conversion :S. Thanks select * from (select * from ( select * from "public"."tabla_procesados" where "state" LIKE ‘%Failed%’ and id_execution = (select max(id_execution) from public.tabla_procesados) order by public.tabla_procesados.ts_start_processing desc ) a limit 1) b where ..

Read more

select s2.itemdesc, to_char(date_trunc(‘month’, saledate), ‘YYYY’) AS year, to_char(date_trunc(‘month’, saledate), ‘Month’) AS month, to_char(date_trunc(‘month’, saledate), ‘MM’) AS month_number, sum(qty) AS qty1 from sale s left join saled s2 on s.saleno = s2.saleno GROUP BY s2.itemdesc, date_trunc(‘month’, saledate) order by s2.itemdesc desc and month desc i have tried query in Postgresql Manager and its work. but i ..

Read more

I have a laravel project which was running using mySQL database and we plan to migrate to PostgreSQL, while migrating this is one of the error I have face, how can I tackle this? IlluminateDatabaseQueryException The auto-commit mode cannot be changed for this driver protected function createPdoConnection($dsn, $username, $password, $options) { if (class_exists(PDOConnection::class) && ! ..

Read more

Error: IlluminateDatabaseQueryException array_diff_key(): Argument #2 is not an array (SQL: select * from "pages" where "slug" = home and "pages"."deleted_at" is null limit 1) Imports use DoctrineDBALDriverPDOConnection; use Exception; use IlluminateDatabaseDetectsLostConnections; use PDO; use Throwable; Error Functions public function getOptions(array $config) { $options = $config[‘options’] ?? []; return array_diff_key($this->options, $options) + $options; } Options Variable ..

Read more

I have a Postgres Function which performs select query on a table to perform an arithmetic operation and calculate the result. I have setup pgbouncer before the postgresql server for better throughput. The System configurations are as follows. NGINX -> PHP-FPM -> Laravel 8 -> PgBouncer -> PostgreSQL 12 System Configuration AWS M6G.8X Large – ..

Read more

I am using PostgreSQL 12. I have ‘users’ table where ’email’ column is nullable means optional column, however it has unique constraint as expected. This ’email’ column is ‘citext’ type column. The problem is even I send ’email’ value as NULL, the database saves it as empty string instead NULL in ’email’ column during insert. ..

Read more

Schema::table(‘student’, function (Blueprint $table) { $table->dropColumn(‘id’); }); I wanted to delete the id column of student table. But this column is already referenced as foreign key(student_id) in table certificates.How can i do that?The above code shows the below error. IlluminateDatabaseQueryException SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR: cannot drop column id of table student because ..

Read more

I have a eloquent query with search. I need to search the value in two relations one in services.service_name and other in item.service name. on checking the item.service_name throwing error "cross-database references are not implemented". Am using laravel 8 with postgresql. $business->categories()->with([‘services.staffs’,’packages.packageItems.item’]) ->when(request()->filled(‘search’), function ($q) { $q->whereHas(‘services’, function ($q) { $q->where(‘services.service_name’, ‘ilike’, ‘%’ . request(‘search’) ..

Read more

When i tried to run php artisan migrate within my running container i got error like could not find driver that i think not properly installed postgres i included the code and error below help me to find this. My docker file FROM php:fpm-alpine RUN set -ex && apk –no-cache add postgresql-dev RUN docker-php-ext-install pdo ..

Read more

I am facing a issue when trying to connect to gcloud postgres db allowing ssl in my laravel application which is running in the cloud run. I downloaded all three cert files from gcloud and set the path in config/database.php. ‘driver’ => ‘pgsql’, ‘host’ => env(‘DB_HOST’, ‘127.0.0.1’), ‘port’ => env(‘DB_PORT’, ‘5432’), ‘database’ => env(‘DB_DATABASE’, ‘forge’), ..

Read more

I was creating docker container for laravel with postgres. containers running but cant find laravel in web. Dockerfile: FROM php:7.4-fpm-alpine RUN docker-php-ext-install pdo pdo_pgsql RUN curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer RUN composer install WORKDIR /var/www/html COPY . . CMD php artisan serve –host=0.0.0.0 EXPOSE 8000 My docker-compose.yml file version: ‘3’ services: php_3: ..

Read more

Please help with code for dockerfile and docker-compose file i need laravel setup and postgres. This is my docker file FROM php:7.4 RUN apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev zlib1g-dev libpq-dev libxml2-dev libzip-dev libonig-dev graphviz && docker-php-ext-configure gd && docker-php-ext-install -j$(nproc) gd && docker-php-ext-install pdo_mysql && docker-php-ext-install pdo_psql && docker-php-ext-install zip ..

Read more