Postingan

Mysql | MariaDB create function, For Loop, Serial Number example

 DROP FUNCTION IF EXISTS max_nomor_anggota; DELIMITER | CREATE FUNCTION max_serial_number(param_1 VARCHAR(255), param_2 VARCHAR(255)) RETURNS VARCHAR(10) BEGIN DECLARE nomor_anggota_var VARCHAR(255); DECLARE nomor VARCHAR(255); DECLARE urut VARCHAR(255); FOR i IN  1..9999 DO SET urut = LPAD(i, 4, "0"); SET nomor = concat(param_1, param_2, urut); IF (SELECT NOT EXISTS(SELECT * from table_name WHERE nomor_anggota = nomor AND id_wilayah=CAST(param_1 as INTEGER) AND id_daerah=CAST(param_2 as INTEGER) ORDER BY nomor_anggota)) THEN  RETURN nomor; END IF; END FOR; RETURN nomor; END  | DELIMITER ; 

cronjob execute different php version or mac os big sur Caused by: Exception 'PDOException' with message 'could not find driver'

Problem is solved: the cron job execution was using a different version of PHP. Different both from the one from Apache and from the one from the CLI. So I just used the explicit path, referencing the correct PHP version. example cron using yii2  * */ 1 * * * /usr/bin/php / var /www/mysite/yii controller/action That should do the trick - provided that you supply the correct paths. To find out what the full path to php is, run this in a console prompt: which php in this case, when cron running console always get error PDO exception

Yii2 costum breadcumb

                       Breadcrumbs :: widget ([ 'itemTemplate' => '<li class="breadcrumb-item"> <i class="fas fa-chevron-right"></i> {link} </li>' , 'activeItemTemplate' => '<li class="breadcrumb-item active"> <i class="fas fa-chevron-right"></i> {link} </li>' , 'homeLink' => [ 'label' => 'Beranda' , 'url' => Yii :: $app -> homeUrl , 'template' => "<li class='breadcrumb-item'> {link} </li> \n " , ], 'links' => isset ( $this -> params [ 'breadcrumbs' ]) ? $this -> params [ 'breadcrumbs' ] : [], ...

React js make submit form not reload page

import React , { useState } from 'react' export default function Home (){ const [ keyword , setKeyword ] = useState ( '' ) const handleSubmit = ( e ) => { e . preventDefault (); // hanlde form not reload page console . log ( keyword ) } return ( < form onSubmit = { handleSubmit } > < input type = "text" value = { keyword } onChange = { ( e ) => e . setKeyword ( e . target . value ) } /> </ form > ) }

Yii2 Cors Origin

Gambar
copy or add to your application in .htaccess Options +FollowSymlinks RewriteEngine on Header always set Access-Control-Allow-Origin "*" Header always set Access-Control-Allow-Headers "*" SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ $1 [R=200,L] example:

Postgresql cannot alter type of a column used by a view or rule

check length type data SELECT atttypmod FROM pg_attribute WHERE attrelid = 'data_utama'::regclass AND attname = 'nomor_sptm'; change type data UPDATE pg_attribute SET atttypmod = 90+4, -- length type data  atttypid='INT'::regtype -- type data WHERE attrelid = 'data_utama'::regclass AND attname = 'nomor_sptm';

postgressql nextval not working after transfer data from maria db

SELECT setval('yourtable_id_seq', (SELECT max(id) FROM yourtable));