I want to get auto-increment id after storing session in session table in zf2 module.php file
following is my code:
$session_id = $sessionManager->getId();
now what i want:
$session_table = $sm->get('session_table');
$resultset = $session_table->select(array(
'id' => $sessionManager->getId()
));
$row = $resultset->current();
$session_last_id = $row['session_id'];
in $session_last_id, I will get the auto-increment id of the particular session id,
Problem is :
I didn't get auto increment id when the session is created. I get the error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'session_id' cannot be null' in E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php:240 Stack trace: #0 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php(240): PDOStatement->execute() #1 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(291): Zend\Db\Adapter\Driver\Pdo\Statement->execute() #2 E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(258): Zend\Db\TableGateway\AbstractTableGateway->executeInsert(Object(Zend\Db\Sql\Insert)) #3 E:\xampp\htdocs\equatmedia_new\module\Equate\Module.php(52): Zend\Db\TableGateway\AbstractTableGateway->insert(Array) #4 [internal function]: Equate\Module->onBootstrap(Object(Zend\Mvc\MvcEvent)) #5 E:\xampp\h in E:\xampp\htdocs\equatmedia_new\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Statement.php on line 245
But once I refresh the page, error removes and I get what i wnat.
Why i should refresh the page..? i want the id without refresh the page and without error.
I need help friends.
Your help will be highly appreciated. Please help me..
Related
I'll like to programmatically schedule a video once uploaded via youtube API... I know the videoId.
Here is my code:
$videos = $youtube->videos->listVideos("snippet, localizations",
array('id' => $videoId));
// Since the request specified a video ID, the response only
// contains one video resource.
$video = $videos[0];
$playlistItemResponse = $youtube->playlistItems->update("snippet, contentDetails, status", $video);
//$playlistItem:Google_Service_YouTube_PlaylistItem
$contentDetails=$playlistItemResponse->getContentDetails();
$contentDetails->setStartAt("2024-12-24T05:42:08.000Z");
I'm getting an error that playlistItems->update requires a playlist not a video...
<b>Fatal error</b>: Uncaught TypeError: Argument 2 passed to Google\Service\YouTube\Resource\PlaylistItems::update() must be an instance of Google\Service\YouTube\PlaylistItem, instance of Google\Service\YouTube\Video given, called in /var/www/html/API/publishCompilation.php on line 217 and defined in /var/www/html/vendor/google/apiclient-services/src/YouTube/Resource/PlaylistItems.php:157
Stack trace:
#0 /var/www/html/API/publishCompilation.php(217): Google\Service\YouTube\Resource\PlaylistItems->update('snippet, conten...', Object(Google\Service\YouTube\Video))
#1 {main}
thrown in <b>/var/www/html/vendor/google/apiclient-services/src/YouTube/Resource/PlaylistItems.php</b> on line <b>157</b><br />
How is the correct way of scheduling a single video?
Thanks
i make project with laravel and i upload it on the heroku i used notifications so data column in notification table stored like {"id":36,"total":"300","tableNum":"6"} these data for order
i used this code to make notification unread
public function show($id) //$id refers to order id in this example id = 36
{
$getId = DB::table('notifications')->where("data->id", $id)->pluck('id');
DB::table('notifications')->where('id', $getId)->update(['read_at' => now()]);
return redirect()->route('current');
}
this code runs without any errors, but in heroku make an error "cast" what can i do ?
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: text ->> unknown
LINE 1: select "id" from "notifications" where "data"->>'id' = $1
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts. (SQL: select "id" from "notifications" where "data"->>'id' = 1)
You have a syntax error in your current example.
->where("data->id", $id)
It should either be "id" or $data->id, but it's hard to assume based from the code you just posted. However, your answer could be simplified by just using this. Don't need to pluck id and use it again for another query
public function show($id) //$id refers to order id in this example id = 36
{
DB::table('notifications')->where('id', $id)->update(['read_at' => now()]);
return redirect()->route('current');
}
After I update my DC.edmx model from the database I'm getting an error during the fetching of data from my "Users" table.
The exception is attached as a screen shot for a better understanding. I just wanted to know what this exception actually saying and what is the possible fix? Any ideas would be appreciated.
var user = ctx.Users.FirstOrDefault(x => x.Email == model.Username);
Go here to see screen shot
I extend angular.dart.tutorial with basic CRUD operations. So in new edit_recipe_component.html I need to add some sort of selection input for recipe categories.
Currently I have
<select ng-model="ctrl.recipe.category">
<option ng-repeat="c in ctrl.categories" value="{{c}}">{{c}}</option></select>
That works perfectly well on the surface: I can select category from the list, selected category is successfully stored in model and so on.
But I get these errors in debug console:
NoSuchMethodError : method not found: 'ngValue'
Receiver: null
Arguments: []
STACKTRACE:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:42)
#1 _SingleSelectMode.onModelChange.<anonymous closure> (package:angular/directive/input_select.dart:185:78)
#2 _SelectMode._forEachOption (package:angular/directive/input_select.dart:146:24)
#3 _SingleSelectMode.onModelChange (package:angular/directive/input_select.dart:183:19)
What I'm doing wrong?
Unfortunately APIDOCS to InputSelectDirective has no usage section
Update: I've created github project based on Chapter 6 sample where problem is reproduced
It is here: https://github.com/vadimtsushko/angular_tutorial_chapter_06
Some debugging shows that setting category in Edit form works immediately and successfully (I've added category in Recipes list view for debug purpose).
Error raised when I leave Edit form.
I believe that this issue has been fixed for a while (hence no need for a patch), but in any case, you could also have used ng-value:
<select ng-model="ctrl.recipe.category">
<option ng-repeat="c in ctrl.categories" ng-value="c">{{c}}</option></select>
do a little patch on _SingleSelectMode class in input_select.dart
onModelChange(value) {
var found = false;
_forEachOption((option, i) {
if (option == _unknownOption) return;
if (expando[option] == null ) return;
var selected = value == null ? option == _nullOption : expando[option].ngValue == value;
found = found || selected;
option.selected = selected;
});
I am counting table rows in MVC view.
The below code was counting from a linked table but has now stoped giving me the following error:
Object reference not set to an instance of an object.
Has anyone any idea as to why this would happen?
#Model.Count(x => x.Device.VehicleReg != null)
You Device is null and throws exception
Try this:
#Model.Where(x=> x.Device != null).Count(x=> x.Device.VehicleReg)
Assuming that Model is not null, probably Device is null that's why you get the "Object reference " error