CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Storing ccuserid() into a mysql db char field [{RESOLVED]

Print topic Send  topic

Author Message
acedrummond


Posts: 90
Posted: 06/27/2011, 8:54 PM

I have field defined in a mysql database as: items_checkin_by as char 8 default NULL permitted.

(I built a screen with grid and record builder and am using only the search and grid while hiding the record portion of the screen. I use the search part and then use SQL to validate the data entered and then update a few fields. All the other updates work fine and I am having a problem where it comes to storing the CCGetUserId() value.)

I can echo the $userid and it is perfect text data. I just can't seem to store it unless the value of the $userid is numeric!


The following code does not store anything to items_checkin_by

$db = new clsDBConnection1();

$userid = ccgetuserid();

$SQL = "Update items set items_checkin_by = ".$userid.
" where items_key = ".$Container->s_items_key->GetValue() ;
$db->query($SQL);
$db->close();

I've tried with same result!

$SQL = "Update items set items_checkin_by = ".CCUserId().
" where items_key = ".$Container->s_items_key->GetValue() ;

If I put a numeric value i.e. '123' into $userid that gets stored on the update.

I don't know why this doesn't work with CCUserID() - can someone please shed some light on this issue for me.

FYI I do many other updates with sql and no problem, but this one I don't understand?

If I do something like this it also populates the record correctly:

$SQL = "Update items set items_checkin_by = 'test' ".
" where items_key = ".$Container->s_items_key->GetValue() ;

Any explanation appreciated. Thanks/
_________________
Ace Drummond
View profile  Send private message
jjrjr2


Posts: 131
Posted: 06/28/2011, 1:53 AM

Try

$SQL = "Update items set items_checkin_by = ".$db->ToSQL($userid,ccsText).
" where items_key = ".$db->ToSQL($Container->s_items_key->GetValue(),ccsInteger) ;

or

$SQL = "Update items set items_checkin_by = ".$db->ToSQL(CCUserId(),ccsText).
" where items_key = ".$db->ToSQL($Container->s_items_key->GetValue(),ccsInteger) ;

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us
View profile  Send private message
acedrummond


Posts: 90
Posted: 06/28/2011, 7:09 AM

Thank you! That solved my problem!

Do you know why the SQL does not like the content of the field to start with?
_________________
Ace Drummond
View profile  Send private message
jjrjr2


Posts: 131
Posted: 06/28/2011, 3:50 PM

Yes...

The userid field is an integer probably and you are trying to put integer data into a field defined as text.

Hence the CCS database class has a method that will convert your data to the appropriate data type for your table in SQL using the proper define sent to that method..

ie:

$db->ToSQL("somevalue", ccsText)

(Assuming the the new database object you created is called $db..)

The example above prepares the data prior to using it in the query to be text for table insertion.

other defines are
ccsInteger
ccsFloat
ccsDate

These used in the second param to the method will perform the same conversion as described by the parameter to create the proper data format required for the field.

There might be some more but I would have to look at the database class

Glad that helped..

John;-) ;-)
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.