Saturday 2 July 2022

Get Data through Model in Codeigniter 4

Table Structure



 Model

<?php

namespace App\Models;
use CodeIgniter\Model;
class ContactModel extends Model
{
      protected $table='holywebcontact';
       protected $primaryKey = 'ID';
       protected $allowedFields = ['ID', 'Name', 'Phone', 'Message', 'CreatedDate'];     

}

Controller

<?php 

namespace App\Controllers;
use App\Models\ContactModel;
class Home extends BaseController
{

     public function dataread()
    {

        $data['title'] = 'DB Get Demo';
       $crudModel = new ContactModel();
        $data['user_data'] = $crudModel->findAll(); 
        return view('tmp2', $data);

    }

}

Note: Below is a list of some different types of conditions/filters for data access.
 
$data['user_data'] = $crudModel->where('id>=','5')->orderBy('id', 'DESC')->paginate(5);

 $data['user_data'] = $crudModel->where('id>=','5','phone','22')->orderBy('id', 'DESC')->paginate(5);

$data["model"]=$album->where('AlbumID', $aid)->findAll();


Get All record with ouder by clause

$data=$GalleryModel->orderBy('ID', 'DESC')->findAll();

View

<?php

foreach ($model as $item)
{
       echo $item["ID"] . "," . $item['Name'] . "<br>";
}

?>

Next Topic

Friday 1 July 2022

Record Save Using Entity Framework

Read Basics of Entity Framework on my previous post for understand this example.

EntityFramework Basics


Date Save Code

 dbConnection db = new dbConnection();

db.Bill.Add(data);

db.SaveChanges();


Next Topic

Wednesday 29 June 2022

Unable to write in session folder in windows 10 using Codeigniter 4

 This post is applied on following Codeigniter Error

  • Unable to write in session folder in windows 10 using Codeigniter 4
  •  SYSTEMPATH\Session\Handlers\FileHandler.php at line 102
  •  Uncaught Exception: Session: Configured save path
  • CodeIgniter\Session\Exceptions\SessionException

Solution 

I solved this issue... for anyone experiencing this... changing permissions to anything didn't work. Somehow they had been corrupted on the actual folder so I deleted the cache folder and session folder and created new folders and replaced the contents (files ended up not being an issue). This fixed my issue.

Note: In my case, this error occurred due to google cloud backup because I was working simultaneously while the backup is running and Google Backup corrupted the session folder. 

Thursday 23 June 2022

Celebrating 10 Years Anniversary SVG Animation

 Celebrating 10 Years Anniversary SVG Animation




Step to create and animate SVG File

SVG is numeric formate of graphic representation. You can create SVG files easily using Coral Draw. Create a graphic in the coral draw and export it in SVG format. One's SVG file was extracted. You will get the code of the entire file in SVG format.

Apply CSS animation code as you apply in HTML file

HTML File Code : 

<html>

<head>

    <title>SVG</title>

</head>

<body>

    <style>

     

    </style>

    <object data="akt.svg" width="500" height="500"> </object>

    <p class="rotate">Lorem</p>

</body>

</html>