Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Recreate migration file from database and tables.

 


Laravel Migration

Recreate migration file from database and tables.

Package : https://github.com/kitloong/laravel-migrations-generator


php artisan migrate:generate 


Possible error: Unknown database type bit requested, Doctrine\DBAL\Platforms\PostgreSQL94Platform may not support it.




Temporary Fixes:

Edit file in line 423: 

vendor\doctrine\dbal\src\Schema\PostgreSQLSchemaManager.php 


 if($dbType=='bit') {

            $dbType = "boolean";

   }

Execute : skipping view and procedure 

php artisan migrate:generate   --skip-views --skip-proc

Programming Basic

Programming Basic

Programming basic
1. Declare variable , Get input and print output in console.

[C Programming]

char s[]; char c; int i; float f;

printf("Enter your website name: ");
scanf("%s", str);
printf("Entered Website:%s", str);

scanf("%d", i);    // integer along with +, - int
scanf("%c", c );   //char single char // char* is string
scanf("%f", f);    //float   others :  e,E,f,g,G
scanf("%lf", f);   //double
scanf("%.2lf", f);   //double 2 decimal digit

scanf("%s", str);                      // string with out space
scanf("%[^\n]", input_string);  // read full line and save to variable

[Javascript]


var a; // It is any data type

console.log("hello");
 process.stdout.write("Hello, World.");


[PHP]

$_fp = fopen("php://stdin", "r");   //open
$inputString = fgets($_fp);  // get a line of input from stdin and save it to our variable
print("Hello, World.\n");    // output
fclose($_fp); //close

[JAVA]

Scanner scan = new Scanner(System.in); //create scanner object to read from stdin
String strinput         = scan.nextLine();       // read full line and save to string variable
double numdouble = scan.nextDouble();
int  numint = scan.nextInt();
scan.close();                                              //close scanner object
System.out.println("Hello, World.");       // display output with stdout

Server feature for optimization

Server feature for optimization

Need to activate these module
- mod_deflate
:  used to compress data using gzip compression

- mod_header
: Customization of HTTP request and response headers

- mod_expires
: Generation of Expires and Cache-Control HTTP headers according to user-specified criteria

- mod_filter, mod_ext_filter
: smart filter configuration module like filter file types

In .htaccess file

#For Expire header
<IfModule mod_expires.c>
ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault                          "access plus 1 month"

# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest       "access plus 0 seconds"

# Your document html
ExpiresByType text/html                 "access plus 0 seconds"

# Data
ExpiresByType application/json          "access plus 0 seconds"
ExpiresByType application/xml           "access plus 0 seconds"
ExpiresByType text/xml                  "access plus 0 seconds"

# Feed
ExpiresByType application/atom+xml      "access plus 1 hour"
ExpiresByType application/rss+xml       "access plus 1 hour"

# Favicon (cannot be renamed)
ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
ExpiresByType audio/ogg                 "access plus 1 month"
ExpiresByType image/gif                 "access plus 1 month"
ExpiresByType image/jpeg                "access plus 1 month"
ExpiresByType image/png                 "access plus 1 month"
ExpiresByType video/mp4                 "access plus 1 month"
ExpiresByType video/ogg                 "access plus 1 month"
ExpiresByType video/webm                "access plus 1 month"

# HTC files  (css3pie)
ExpiresByType text/x-component          "access plus 1 month"

# Webfonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf    "access plus 1 month"
ExpiresByType application/x-font-woff   "access plus 1 month"
ExpiresByType font/opentype             "access plus 1 month"
ExpiresByType image/svg+xml             "access plus 1 month"

# CSS and JavaScript
ExpiresByType application/javascript    "access plus 1 year"
ExpiresByType text/css                  "access plus 1 year"
</IfModule>

#For gzip compression
<IfModule mod_deflate.c>
AddOutputFilter DEFLATE php
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
</IfModule>

#unset Etags
Header unset ETag
FileETag None

Yii Database Query

Yii Database Query

Cheatsheet Example


CDB command Update

$id = 5;
$modified_on = NOW; 
$sql = "UPDATE table SET modified_on='".$modified_on."', name='hello ' WHERE result_id=:result_id"; 
$command = Yii::app()->db->createCommand($sql);
$command->bindParam(":result_id", $id , PDO::PARAM_STR );
$command->execute();

CDB command query

$sql = "SELECT action_id FROM action_testcase where testcase_id ='".$this->testcase_id."';";
$cmd = Yii::app()->db->createCommand($sql);
$result = $cmd->queryRow();
$action_id = $result['action_id'];