Hi all
I am creating a new module for this i have created a new database.
I can load from this database but when i try to save to it it does not do what i expected.
I have the following code :
$stn = 1;
$storesection = storesection_load($stn);
print_r ($storesection);
$storesection[1]->caption = 'No body nows';
print_r ($storesection);
$check = storesection_save($storesection[1]);
print $check;
==== functions =====
function storesection_load($id, $reset = FALSE) {
return storesection_load_multiple(array($id), $reset);
}
/**
* Load multiple records.
*/
function storesection_load_multiple($ids = array(), $conditions = array(), $reset = FALSE) {
return entity_load('storesection', $ids, $conditions, $reset);
}
function storesection_save($storesection) {
$result=db_query("SELECT aid FROM storesection WHERE sectionid=:proid",array( ':proid' => $storesection->sectionid,));
$sid = $result->fetchField(0);
print '
';
print '
';
print_r ($sid);
if(empty($sid )){
// Adds the data to the entity table, and returns the new $storesection_id:
$aid = db_insert('storesection')
->useDefaults(array('aid'))
->fields(array(
'created' => REQUEST_TIME,
// Any other DB columns that you want to provide defaults for.
))
->execute();