Tag : Column


Laravel 5 - where condition with two columns example code

Laravel 5 introduce whereColumn() in Query Builder, that way we can compare two column like simple where condition. We sometimes require to check this type of condition. In this example code, i have simple "items" table and i want to get only created_at and updated_at column should equals. So you can also check bellow laravel eloquent as bellow: <strong>Example:</strong> <pre class="prettyprint lang-php"> $data = DB::table("items") ->whereColumn('created_at','updated_at') ->get(); print_r($data); </pre> <strong>Example 2:</strong> <pre class="prettyprint lang-php"> .....

By Hardik Savani | July 29, 2016 | | 2047 Viewer | Category : Laravel
READ MORE

Laravel - How to remove foreign key constraint using migration?

Sometimes it can be agreeable to remove a database column that hosts a foreign key relationship, and we add wrong column with foreign key constraint on table, At that time we must remove that column from table. But we can't remove directly using dropColumn() because we did apply foreign key constraint so we should drop foreign key constraint of that column using dropForeign() and then we can delete column using dropColumn(). You can see as bellw migration, first i added migration with wrong column then other migration for remove that column. <strong>Wrong Column Migration:</strong> <pre cla.....

By Hardik Savani | July 1, 2016 | | 3422 Viewer | Category : Laravel
READ MORE

Sql function remove numeric characters from column example

Mysql custom fucntion is a very prety and intresting concept. In this posts i want to create one custom mysql function for remove numeric characters from table field value. this function through you can also remove numeric characters from string in mysql. in following sql query fire in your mysql or mssql database and check how it works. So, lets create function and how to use in select statement in sql query. <strong class="step">Create removeNumber function:</strong> <pre class="prettyprint lang-mysql"> DROP FUNCTION IF EXISTS removeNumber; DELIMITER | CREATE FUNCTION removeNumber( str CH.....

By Hardik Savani | March 12, 2016 | | 820 Viewer | Category : PHP MySql SQL MSSQL
READ MORE

How to remove special characters by mysql custom function.

Mysql custom fucntion is a very prety and intresting concept. In this posts i want to create one custom mysql function for remove special characters from table field value. this function through you can also remove special characters from string in mysql. in following sql query fire in your mysql or mssql database and check how it works. So, lets create function and how to use in select statement in sql query. <strong class="step">Create removeSpacialChar function:</strong> <pre class="prettyprint lang-mysql"> CREATE FUNCTION `removeSpacialChar`(`in_str` varchar(4096)) RETURNS varchar(4096) C.....

By Hardik Savani | March 10, 2016 | | 3442 Viewer | Category : PHP MySql SQL MSSQL
READ MORE

    Laravel 5 - Example of Database Seeder with insert sample data

    Laravel 5 - Example of Database Seeder with insert sample data

    Open Post

    Laravel 5 dynamic autocomplete search using select2 JS Ajax - Part 2

    Laravel 5 dynamic autocomplete search using select2 JS Ajax - Part 2

    Open Post

    Bootstrap - maxlength validation with count remaining character example

    Bootstrap - maxlength validation with count remaining character example

    Open Post

    Laravel 5.2 - User ACL Roles and Permissions with Middleware using entrust from Scratch Tutorial

    Laravel 5.2 - User ACL Roles and Permissions with Middleware using entrust from Scratch Tutorial

    Open Post

    Laravel - How to search with comma separated values using Query Builder ?

    Laravel - How to search with comma separated values using Query Builder ?

    Open Post

    How to add multiple markers in google map

    How to add multiple markers in google map

    Open Post