Jump to content


Photo

PutIntTableRow.... Active Development?


  • Please log in to reply
4 replies to this topic

#1 traderhut

traderhut

    Etomite Forum Newbie

  • Member
  • 18 posts

Posted 04 October 2010 - 05:30 PM

Hi,

I made the following change to the Index.php, in the end of the routine PutIntTableRow()


$sql = "INSERT INTO $tbl SET ";
foreach($fields as $key=>$value) {
$sql .= "`".$key."`=";
if ($value == null) $sql .= 'null,';
else
if (is_numeric($value)) $sql .= $value.",";
else $sql .= "'".$value."',";
}


Perhaps, there is another way to handle this, but looking at the code, I don't see one.. I wanted to set a column to the value null, however, the code will attempt to set it to '', which MySQL isn't taking as null. (Oracle does, which drives me nuts, but that is another topic)


This change allows the value to be set as:


$values= array(
'CubeID' => $CubeID,
'GroupDescription' => $GroupName,
'created_at' => null
);

$etomite->putIntTableRow($values, "Cubes");

Allowing a column that is a timestamp to be updated to the current time, which can not be done on the SQL Server (if you also have a On Update timestamp column)

(I'm guessing the same change should be added to the update code, as well as code for External tables/db)

-Chert

PS: Last I heard there was active development on etomite. Would said developers be interested in my helping develop? I hate to have "my own version" of the source, Or even a set of patches that I'll have to apply when the next version comes out... (I'd be interested to know if/when this gets put into the main line, so I know I won't have to worry about it in the future...)

---
Runecube.Com

#2 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 05 October 2010 - 05:15 PM

I'm sure there is room for improvement for the putIntTableRow() and putExtTableRow() functions... They have worked within expectations for my custom coding needs as I use the get functions far more often than the put functions... If the data is properly validated prior to saving there shouldn't be any problems, however...

#3 traderhut

traderhut

    Etomite Forum Newbie

  • Member
  • 18 posts

Posted 06 October 2010 - 07:25 PM

I'm sure there is room for improvement for the putIntTableRow() and putExtTableRow() functions... They have worked within expectations for my custom coding needs as I use the get functions far more often than the put functions... If the data is properly validated prior to saving there shouldn't be any problems, however...


It isn't a matter of properly validated. Try to set a field to null using the PutIntTableRow() function. You can't, unless you add the change that I made.

-Chert

#4 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 07 October 2010 - 01:13 PM

It isn't a matter of properly validated. Try to set a field to null using the PutIntTableRow() function. You can't, unless you add the change that I made.

-Chert


I'll have to look into this as the code base should already have code to account for both strings and numerics...

Which release are you working with...???

#5 traderhut

traderhut

    Etomite Forum Newbie

  • Member
  • 18 posts

Posted 07 October 2010 - 03:58 PM

I'll have to look into this as the code base should already have code to account for both strings and numerics...

Which release are you working with...???



The latest, And yes, it handles strings and numerics... Strings have ' s around them.. .I.E. 'Null' and Numerics are passed in as the numeric value.. 0... but if the value is NULL, then you wan to just pass null to the SQL.

See the code posted, all I did was add a simple check for the value being null before doing the other check. It's a one-line-er change, but useful if you need to store NULL into a database field.

-Chert




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users