Support Forum
I will try to explain the problem I am facing please excuse if anything wrong. I did not change any code first and I have tired by updating the Name of the project by adding autosync: true then I am getting the error
Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\jmsdemo\gantt-1.0.2-trial\examples\php\php\Bryntum\CRUD\SyncHandler.php on line 109
So I have cross verify the code in SyncHandler.php is calling handleAdded function so I have removed that one .
Now it is going to handleUpdated updated function. below is the code for that function
Below is the update function
In above I have done below change
and also in In BaseDAO.php I done changes like
in below function
and tired again I can see below json response in console
May I know what is the reason ? and also by seeing the function can you please confirm I am using correct code
Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\jmsdemo\gantt-1.0.2-trial\examples\php\php\Bryntum\CRUD\SyncHandler.php on line 109
{"success":false,"requestId":"15604977034752","message":"Cannot update server revision stamp.","code":6}
$mode == ADDED_AND_UPDATED_ROWS
public function handle($request, $mode = ALL_ROWS)
{
$res = array();
if ($mode == ALL_ROWS || $mode == META_DATA) {
$this->handleMetaData($request, $res);
}
if ($mode == ALL_ROWS || $mode == ADDED_ROWS) {
$this->handleAdded($request, $res);
}
if ($mode == ALL_ROWS || $mode == UPDATED_ROWS || $mode == ADDED_AND_UPDATED_ROWS) {
$this->handleUpdated($request, $res);
}
if ($mode == ALL_ROWS || $mode == REMOVED_ROWS) {
$this->handleRemoved($request, $res);
}
if ($mode == ALL_ROWS) {
if (@!$res['rows'] && @!$res['removed']) {
throw new \Exception('No data to save.', E_APP_NO_SYNC_DATA);
}
}
return $this->onHandled($res);
}
}
public function handleUpdated($request, &$response)
{
$updated = null;
if (isset($request['updated'])) {
$updated = array();
foreach ($request['updated'] as $row) {
$r = $this->update($row);
$updated[] = $this->onRecordUpdated($row, $r);
}
}
if (!$response) {
$response = array();
}
if (sizeof($updated)) {
$response['rows'] = @$response['rows'] ? array_merge((Array)$response['rows'], (Array)$updated) : $updated;
}
return $this->onUpdatedHandled($response);
}
public function update($table, $data, $where = null, $check_cols = true)
{
$cols = null;
// if we need to restrict columns
if ($check_cols) {
// if array of columns provided
if (is_array($check_cols)) {
$cols = &$check_cols;
} else {
// let's get array of columns from database
$cols = $this->getTableCols($table);
}
}
$_data = [];
$sql = "update $table set ";
foreach ($data as $field => $value) {
if (!$cols || isset($cols[$field])) {
if ($value === null) {
$sql .= " `$field` = null,";
} else {
$sql .= " `$field` = ?,";
$_data[] = $value;
}
}
}
$sql = rtrim($sql, ',');
if ($where) {
$sql .= ' where '.self::buildWhere($where, $_data);
}
$stmt = $this->db->prepare($sql);
return $stmt->execute($_data);
}
$sql .= " `$field` ='$value',";
$_data[] = $value;
$sql .= " and `$field` = $value";
$values[] = $value;
public static function buildWhere($where, &$values)
{
$sql = ' 1=1 ';
foreach ((array)$where as $field => $value) {
if ($value === null) {
$sql .= " and `$field` is null";
} elseif (is_array($value)) {
$sql .= " and `$field` in ". self::buildWhereIn($value);
$values = array_merge($values, $value);
} else {
$sql .= " and `$field` = ?";
$values[] = $value;
}
}
return $sql;
}
success false
requestId 15604987565382
message Cannot update server revision stamp.
code 6
When I press on create button it is creating a task in database with default name NewTask . This is fine but when I am editing the same task name into other name without refreshing the page it is creating another record with updated name in database .if I refresh the page it is not happening . should I need to add anything to work this without refresh
Please see docs: https://bryntum.com/docs/gantt/#Gantt/feature/TaskEditAnd also From where I can found the popup of task information
Probably your server is not responding in the format we expect, and you need to read the docs here:When I press on create button it is creating a task in database with default name NewTask . This is fine but when I am editing the same task name into other name without refreshing the page it is creating another record with updated name in database .if I refresh the page it is not happening . should I need to add anything to work this without refresh
https://bryntum.com/docs/gantt/#guides/crud_manager.md
If that is the case it will not create a task in database when I press create a task button I guess. Actually I have turn off theProbably your server is not responding in the format we expect, and you need to read the docs here:
$app->checkRevision($request['revision']); in sync.php
Actual problem is not only changing the name once I created a task from Create button if edit the name or duration or changing anything in the task editor popup it is creating the multiple task instead of updating the same task. Is there any way to auto load the gantt once task is created . I have tired below but still I am facing the issue
const project = window.project = new ProjectModel({
// Let the Project know we want to use our own Task model with custom fields / methods
autoSync : true,
autoLoad : true,
Hello,
autoLoad is not related to the problem you described.
autoLoad loads data as soon the store is created. Please see the docs: https://www.bryntum.com/docs/gantt/#Gantt/model/ProjectModel#config-autoLoad
In our PHP demo if you comment out code starting from line 144
and reload the page, you'll see no records in the grid.
If you add
you can see records are there. So autoLoad works fine.
Here they are:
https://app.assembla.com/spaces/bryntum/tickets/8712-php-demo--after-creating-a-new-task-and-saving-it-ui-is-blocked-and-it/details
https://app.assembla.com/spaces/bryntum/tickets/8715-php-demo--after-creating-a-new-task-and-saving-it-selection-is-broken/details
When 8712 is done will check your testcase and get back to you with an update. Stay tuned!
Thanks,
Pavel
autoLoad is not related to the problem you described.
autoLoad loads data as soon the store is created. Please see the docs: https://www.bryntum.com/docs/gantt/#Gantt/model/ProjectModel#config-autoLoad
In our PHP demo if you comment out code starting from line 144
//project.load().then(() => {...
If you add
const project = window.project = new ProjectModel({
autoLoad : true,
I've checked the latest Gantt demo and found 2 critical issues, so I cannot open TaskEditor to check your scenario.Actual problem is not only changing the name once I created a task from Create button if edit the name or duration or changing anything in the task editor popup it is creating the multiple task instead of updating the same task. Is there any way to auto load the gantt once task is created
Here they are:
https://app.assembla.com/spaces/bryntum/tickets/8712-php-demo--after-creating-a-new-task-and-saving-it-ui-is-blocked-and-it/details
https://app.assembla.com/spaces/bryntum/tickets/8715-php-demo--after-creating-a-new-task-and-saving-it-selection-is-broken/details
When 8712 is done will check your testcase and get back to you with an update. Stay tuned!
Thanks,
Pavel
Pavlo Miklashevych
Sr. Frontend Developer