Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:28:05+00:00 2026-05-29T06:28:05+00:00

I need a way to insert images into a PostgreSQL database without using forms.

  • 0

I need a way to insert images into a PostgreSQL database without using forms. I have a folder that contains a set of images named say aa.jpg, bb.jpg …. zz.jpg. I also have a table that contains the names aa,bb…zz as individual records.

Now my question is how do I insert these images into the DB without manually using forms. There are loads of Yii tutorials to do the manual insertion, but none explaining how to do it programmatically.

Basically I need a way to use lo_import function in Yii. The thing is, image is a column in the table whose type is OID and my insertion code in Yii is as follows

update('table_name', array(
                'image' => "lo_import('$image_path')",
                    ), 'column=:name', array(':name' => $name));

on executing this, it gives me the following error

CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type oid:

Solution: Ok, so following @Uday’s answer, I just used the function in Yii to execute sql statements directly.

Yii::app()->db->createCommand($Update_sql_command)->query();

I am all ears if there is a better way to do this.
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:28:07+00:00Added an answer on May 29, 2026 at 6:28 am

    Do you really need Yii for that? write a function to iterate through all images use get_file_contents() to get contents and store it to mysql.

    $imgContents = get_file_contents('file.Name') ;
    $sql = 'insert into table_name (blob_column) values("'. $imgContents.'")';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a way to insert new articles straight into my MediaWiki database without
I need to insert about 500 images to database at once. I have a
I just need a way to insert an image into the header of a
I need to figure out a way to insert a record with a java.util.Date
I need a way to recursively delete a folder and its children. Is there
I need a way to bind POJO objects to an external entity, that could
I have X number of image objects that I need to loop through in
I wonder is there a way to replicate insert chart dialog functionality using C#.
I'm creating an application that, amongst other things, allows users to insert images on
Need a way to allow sorting except for last item with in a list.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.