Articles on Trending Technologies

Technical articles with clear explanations and examples

How to update a query on Laravel Fluent using db::raw?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 6K+ Views

You can use DB::raw() when you want to execute arbitrary SQL strings inside Laravel's Fluent query builder. This is particularly useful for complex SQL expressions or when you need to bypass Laravel's query builder methods. Note: To work with DB::raw(), you need to include the DB facade class: use Illuminate\Support\Facades\DB; Using DB::raw() with Update Query You can use DB::raw() within the update() method to pass raw SQL values −

Read More

An Uncommon representation of array elements in C/C++

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 185 Views

In C, array elements can be accessed in several ways. While the most common method is using the subscript operator (array[i]), we can also use pointer arithmetic to access elements in an uncommon but valid representation. Syntax *(array + index) // Equivalent to array[index] Example: Pointer Arithmetic Array Access This example demonstrates how to access array elements using pointer arithmetic instead of the traditional subscript notation − #include int main() { int array[5] = {7, 7, 7, 6, 6}; ...

Read More

Why C treats array parameters as pointers?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 343 Views

In C, array parameters are automatically converted to pointers when passed to functions. This behavior is a fundamental design decision that improves memory efficiency and prevents unnecessary copying of large data structures. Syntax void function(int arr[]); // Array parameter syntax void function(int *arr); // Equivalent pointer syntax void function(int arr[10]); // Size is ignored Why Arrays Become Pointers When you pass an array to a function, C automatically passes the address of the first element instead of copying the entire array. This approach offers several advantages ...

Read More

How to chunk results from a custom query in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 7K+ Views

In Laravel, the chunk() method is essential for processing large datasets efficiently. It retrieves data in smaller batches, preventing memory exhaustion when dealing with thousands of records. The method works with both DB facade and Eloquent models. Using DB Facade The chunk() method fetches records in specified batch sizes and processes them within a closure − This example processes 100 records at a time until all records are fetched and displayed. Stopping Chunk Processing You can halt the chunking process by returning false from the closure − ...

Read More

Initialization of a multidimensional arrays in C/C++

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 313 Views

Multidimensional arrays in C are arrays of arrays, where each element is itself an array. They are used to represent data in multiple dimensions like matrices, tables, or grids. The most common type is a 2D array, but C supports arrays of any dimension. 3D Array Memory Layout (2×2×2) Layer 0 [0][0][0] [0][0][1] [0][1][0] ...

Read More

How do Laravel Eloquent Model Attributes map to a table?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 3K+ Views

Laravel Eloquent is an object-relational mapper (ORM) that provides an elegant way to interact with databases. Each table in your database corresponds to an Eloquent model that handles all operations on that table. Model and Table Mapping Convention Laravel follows a specific naming convention for mapping models to tables. If you have a table called users, the model should be named User (singular). Similarly, customers table maps to Customer model. This plural table − singular model pattern is Laravel's default convention, though you can customize it as needed. Database Configuration Before working with models, ensure ...

Read More

How to check database connections in Laravel?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 24K+ Views

Laravel provides several ways to check database connections. The database configuration is stored in config/database.php, and connection details are defined in the .env file. Database Configuration The default database configuration in config/database.php ? 'default' => env('DB_CONNECTION', 'mysql'), Your .env file should contain the database credentials ? DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=test DB_USERNAME=root DB_PASSWORD= Using Controller Method Test database connection within a controller using DB::connection() ?

Read More

How to detect integer overflow in C/C++?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 516 Views

Integer overflow occurs when an arithmetic operation produces a result that exceeds the maximum value that can be stored in the data type. Detecting overflow before it happens is crucial for preventing undefined behavior and security vulnerabilities in C programs. Syntax // For addition overflow detection if (a > MAX_VALUE - b) { // Overflow would occur } // For unsigned addition if (result < operand1 || result < operand2) { // Overflow occurred } Method 1: Pre-computation Check for Signed Integers The safest approach ...

Read More

How to select count with Laravel's fluent query builder?

Shilpa Kalangutkar
Shilpa Kalangutkar
Updated on 15-Mar-2026 18K+ Views

Laravel's fluent query builder provides an elegant interface for creating and running database queries. It includes built-in protection against SQL injection attacks through PDO parameter binding and supports aggregate methods like count(), min(), max(), avg(), and sum(). To use the fluent query builder, import the DB facade class − use Illuminate\Support\Facades\DB; Let's explore different methods to get count values using Laravel's query builder. We'll use a students table with the following structure and data ? CREATE TABLE students( id ...

Read More

Convert a floating point number to string in C

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 10K+ Views

In C, converting a floating point number to a string is accomplished using the sprintf() function. This function works similarly to printf(), but instead of printing to the console, it writes the formatted output to a string buffer. Syntax int sprintf(char *str, const char *format, ...); Parameters: str − Pointer to the destination string buffer format − Format string specifier (e.g., "%f" for float) ... − Variable arguments to be formatted Example 1: Basic Float to String Conversion The following example demonstrates converting a floating point number to a string using ...

Read More
Showing 22011–22020 of 61,297 articles
Advertisements