Skip to main content

Posts

insert document in collection mongodb

 Insert document in collection Two types of insert Insert single records:  Insert multiple records Insert single records:    syntax:  db.collection.insertOne(    <document>,    {       writeConcern: <document>    } ) Example 1:  db.users.insertOne({"name":"ram","email":"ram@gmail.com"})  Example 2:  db.users.insertOne( [{"employee":{"name":"ram","email":"ram@gmail.com"}}] ) Insert multiple records:   syntax : db.Collection_name.insertMany( [<document 1>, <document 2>, …], {     writeConcern: <document>,     ordered: <boolean> }) Example:  db.users.insertMany([{"name":"ram","email":"ram@gmail.com"},{"name":"raju","email":"raju@gmail.com"}])

Collection Shell Commands in MongoDB

Create Collection  Syntax: db.createCollection("Collection Name"); Example: db.createCollection("users"); Delete collection in Mongodb Shell Command db.collection.drop()  Find Collection in Mongodb Shell Command db.collection.find() Show all Collection in Mongodb Shell Command show collections Creat Collection in Mongodb Shell Command db.createCollection("users") Rename the Collection In Mongodb Shell Command db.collection.renameCollection()   Update the single document in MongoDB collections Shell Command db.collection.updateOne()  Updates all the documents in MongoDB collections that match the given query.  db.collection.updateMany() Replaces the first matching document in MongoDB collection db.collection.replaceOne()  Deletes the first document in Mongodb collection db.collection.deleteOne()  db.collection.deleteMany()

Create Show and Delete Database in MongoDB

  Create Database Shell Command Syntax:    use databaseName Example:  use newproject  Description: "use database" syntax to create the database in MongoDB. if database exists switch to that database. Show Databases Shell  Command show dbs Delete Database Shell Command db.dropDatabase() 

PHP7.0 Features

Amazing features of php7 versions  1. Increase the performance. 2. Standalone Multi-threading Web Server 3.Just in time compilation 4. Abstract syntax tree  

Sql group by query

$sql = "SELECT *,count(`created_on`) as blogcount FROM `tbl_blog` group by DATE_FORMAT(`created_on`,\'%M %Y\') order by created_on asc";

codeigniter interview questions and answers for 2 year experience

codeigniter interview questions and answers for 2 year experience 1.what is the Codeigniter? Ans: Codeigniter is open source, webapplication a PHP framework. Codeigniter is loosely based on MVC pattern simple framework in php. 2.What is the current version of codeigniter? The lastest version 2.2.0 till 6-05-2014. 3.what are the features of codeigniter? Ans: 1. codeigniter is open source, webapplication framework. 2.codeigniter is light weight framework. 3.codeigniter faster than any other farmework. 4.codeigniter search engine friendly urls generator. 5.codeigniter is easy exensible. 4. Explain codeigniter file structure. Application -cache -config -controllers -core -errors -helpers -hooks -languages -logs -models- -thirdparty -view system -core -database -fonts -helpers -language -libraries what is mvc framework?  Controller: The controller serves as an intermediary between the model and view. MOdel: The model represents your data stru...

drupal folder structure explained

drupal folder structure explained /includes: Drupal api files are include here.   /database   /mysql   /pgsql   /sqlite   /filetransfer /misc :javascript file and images here.   /farbtastic   /ui   /images /modules : Drupal core modules here. /profiles : installation profiles here   /minimal   /standard   /testing /scripts : shell scripts for developers and administrators here. /sites : all files that are added by a developer to create a site here.   /all      /modules      /themes  /default /themes:  php files: authorize.php cron.php index.php install.php update.php xmlrpc.php htaccess text files: web upgrade robots readme maintainers licenes install

php array interview questions and answers in php

what is an array? Ans: An array stores multiple values in one single variable how to get the first value of an array in php Ans:current() also works on objects: <?php   echo current((object) array('one', 'two')); // Outputs: one ?> And echo reset($arr); $firstValue = each($array)[1]; how to get the last value of an array in php Ans: echo end($array); 3.adding an element in beginning of array Ans: $queue = array("orange", "banana"); array_unshift($queue, "apple", "raspberry"); 4.Insert "elements" to the end of an array Ans: $a=array("red","green"); array_push($a,"blue","yellow"); 5. how to delete the last element of an array in php Ans: $stack = array("orange", "banana", "apple", "raspberry"); $fruit = array_pop($stack); 6. how to delete the first element of an array in php Ans: $stack = array(...

php interview questions and answers for two year experienced

php interview questions and answers for two year experienced 1Q:  What is the difference between the functions unlink and unset? Ans: unlink() deletes the given file from the file system.      unset() makes a variable undefined. 2Q:  How many ways we can pass the variable through the navigation between the pages? Ans: GET, QueryString, POST 3Q:  How can we know the count/number of elements of an array? Ans:  2 ways      a) sizeof($urarray) This function is an alias of count()      b) count($urarray) 4Q:  How can we convert the time zones using PHP? Ans: date_default_timezone_set('Asia/Tokyo'); 5Q:  How many ways can we get the value of current session id? Ans: session_id() returns the session id for the current session. 6Q:   How can we destroy the session, how can we unset the variable of       a session? Ans:  session_unregister รข€” Unregister a global vari...

drupal interview questions and answers for 2 years experience

drupal interview questions and answers for 2 years experience Compare Joomla and Drupal Terminology Joomla Template is called Theme in Drupal. Component = Module. Module = Block. Mambot/Plugin = Input filter. Menu-Horizontal = Primary Links Menu-Vertical = Navigation Dynamic Content Item = Story Static Content = Page Back-end = there is no back-end in Drupal, SEF = Clean URLs (but some docs refer to SEF, too). Section = Taxonomy Vocabulary/Term Section Title = Taxonomy Term (master) Category = Taxonomy Term (child) Introtext = Teaser Maintext = Body (see explanation below) Pathway = Breadcrumb Q: Drupal current version ? Answer:- The Drupal current varsion is 7.21 Q:What is Drupal ? Drupal is an open-source platform and content management system for building dynamic web sites offering a broad range of features and services including user administration, publishing workflow, discussion capabilities, news aggregation, metadata functionalities using controlled ...

how to get the first 500 record from table in php mysql mysql

we are geting first 500 record form table using php and mysql mysql_connect("hostname", "username","") mysql_select_db("databasename"); $sql = "SELECT * FROM table ORDER BY id DESC LIMIT 50"; $result = mysql_query($sql);   while ($query = mysql_fetch_assoc($result))     {     echo "$query[fieldname1] $query[fieldname2] <br/>"; }

find visitor location php

<?php function geoCheckIP($ip)   {   //check, if the provided ip is valid   if(!filter_var($ip, FILTER_VALIDATE_IP))   {   throw new InvalidArgumentException("IP is not valid");   }   //contact ip-server   $response=@file_get_contents('http://www.netip.de/search?query='.$ip);   if (empty($response))   {   throw new InvalidArgumentException("Error contacting Geo-IP-Server");   }   //Array containing all regex-patterns necessary to extract ip-geoinfo from page   $patterns=array();   $patterns["domain"] = '#Domain: (.*?)&nbsp;#i';   $patterns["country"] = '#Country: (.*?)&nbsp;#i';   $patterns["state"] = '#State/Region: (.*?)<br#i';   $patterns["town"] = '#City: (.*?)<br#i';   //Array where results will be stored   $ipInfo=array();   // &nbsp;   //check response from ipserver for above patterns   foreach ($pa...

how to get google map coordinates by address in php

<?php function getCoordinates($address){ $address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address"; $response = file_get_contents($url); $json = json_decode($response,TRUE); //generate array object from the response from the web return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']); } echo getCoordinates('Hyderabad, Andhra Pradesh, India'); ?>