Re: DataObject insert problem

From: Date: Thu, 11 Mar 2004 06:44:43 +0000
Subject: Re: DataObject insert problem
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11224@lists.php.net to get a copy of this message
Ok.. been testing this here. (on another issue..) - I dont have MSSQL to test (which I presume this is). but it should be quite simple to fix. You need to run the generator with a debuglevel of 3 (it will then dump the table structure it finds) - something like the info below.. -- can you send me the [name] => data block. Regards Alan
db_dataobject_generator   : defs       : Array
(
    [0] => Array
        (
            [table] => itemtest
            [name] => id
            [type] => int4
            [len] => 4
            [flags] => not_null default_nextval(items_seq::text) unique primary
        )
    [1] => Array
        (
            [table] => itemtest
            [name] => word
            [type] => varchar
            [len] => -1
            [flags] => not_null unique
        )
Ryan King wrote:
For some reason, the SQL you sent did not work (may not be a SQL server construct). But, here's the script that the Enterprise Manager spit out. CREATE TABLE [dbo].[media] ( [id] [int] IDENTITY (1, 1) NOT NULL , [data] [image] NOT NULL , [created_datetime] [datetime] NULL , [short_description] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [type] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [file_name] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [long_description] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] And here's the SQL I used to create the table. CREATE TABLE media (
    id			            int 		    IDENTITY (1,1) NOT NULL ,
    data		            image           NOT NULL,
    created_datetime	    datetime	    DEFAULT NULL,
    short_description	    varchar(50)	    DEFAULT NULL,
    type		            text		    NOT NULL,
    file_name		        varchar(100),
    long_description	    text,
    CONSTRAINT mediaPK PRIMARY KEY (id)
); Thanks, Ryan On Wednesday, March 10, 2004, at 08:58AM, Alan Knowles <alan@akbkhome.com> wrote:
Ryan King wrote:
Sorry for the slowness.. Here's my media section: [media] id = 129 data = 257
The Generator thinks this is a MySQL TIMESTAMP.. - can you send me the output from SHOW CREATE TABLE media; Regards Alan
created_datetime = 14 short_description = 2 type = 130 file_name = 2 long_description = 2 Thanks, Ryan On Monday, March 08, 2004, at 04:52PM, Norbert Mocsnik <pear-general@mocsnik.hu> wrote:
Hello, Could you send the [media] section from your databasename.ini to the list? Regards, Norbert Ryan King wrote:
$media = DB_DataObject::factory('media'); $media->setId($id); $media->setShort_description($short_description); $media->setLong_description($long_description); if (is_file($_FILES['media']['tmp_name'])) { $media->setType($_FILES['media']['type']); $media->setFile_name($_FILES['media']['name']); $file_path = $_FILES['media']['tmp_name']; $data = file_get_contents($file_path) or die( "Can't open file!" ); $media->setData(base64_encode($data)); } When I then call $media->insert(), the sql that is produced does not include the 'data' field. When I dump the $media object, the encoded file is in the object, but for some reason does not get included in the sql insert statement. I've poked around in the DataObject source, but have not been able to figure out what's going on. -Ryan --------- http://homepage.mac.com/ryansking/
-- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--------- http://homepage.mac.com/ryansking/
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com
--------- http://homepage.mac.com/ryansking/
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.general (#11224) next »