cereal 1,524 Nearly a Senior Poster Featured Poster

To extend the query to all users just remove the name condition from the WHERE clause:

SELECT * FROM `user` WHERE `expires_at` < DATE_ADD(NOW(), INTERVAL 15 DAY);

and it should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

I see that php presentation and word has bug. May I ask you a question if there is some other way that i can view my office document file locally with my wamp server??

I don't know how this will performe in production servers, but as local solution you could install LibreOffice and perform an headless conversion from command line, something like:

exec("soffice --invisible --headless --convert-to odt file.docx");

More info here: https://help.libreoffice.org/Common/Starting_the_Software_With_Parameters

For the options: just switch from -- to - in case of Windows environment.

In reference to the bugs I would submit them to PHPOffice, these libraries have a user large base, so it's possible that your issues have already be covered and you could get some help or temporary workarounds.

diafol commented: perseverence +1 +15
rproffitt commented: Headless thinking. What a concept. +1 +6
cereal 1,524 Nearly a Senior Poster Featured Poster

You have to require the autoload script. But I see that also the Common library is needed. The easiest way to install this package is through composer. Can you use it?

Composer is a packager manager for PHP, it gives you access to many libraries listed in:

Once installed it's easy to start using PHPOffice:

composer require phpoffice/phppresentation dev-master

This will install also the dependencies packages.

In order to do this manually create a src directory, then download both master zip files:

go into each src directory and copy the Common and the PHPPresentation folders into the src directory you generated, then use a script like this:

<?php

    require_once './src/PhpPresentation/Autoloader.php';
    \PhpOffice\PhpPresentation\Autoloader::register();

    require_once './src/Common/Autoloader.php';
    \PhpOffice\Common\Autoloader::register();

    $filename  = './samples/resources/Sample_12.pptx';
    $new_name  = './file.odp';
    $phpPPTX   = \PhpOffice\PhpPresentation\IOFactory::load($filename);
    $odpWriter = \PhpOffice\PhpPresentation\IOFactory::createWriter($phpPPTX, 'ODPresentation');
    $odpWriter->save($new_name);

You can see a live example here:

Which can be downloaded. To see it at work just type php index.php into the terminal, it will convert the sample file into odp.

cereal 1,524 Nearly a Senior Poster Featured Poster

For excel or doc files refer to the other PHPOffice projects:

The code would be similar, where instead of calling PhpPresentation you would load PhpWord or PhpExcel. In the source code of the IOFactory class you can see which drivers are supported:

For more information look at their developer documentation.

IOFactory::load() is a static method to load a resource file, the createWriter() method is used, in this case, to convert the loaded file to another format, the segment \PhpOffice\PhpPresentation\ is the namespace in which the IOFactory class is loaded:

cereal 1,524 Nearly a Senior Poster Featured Poster

The loop attribute works fine for me with this test:

<marquee behavior="scroll" loop="2" scrollamount="4" direction="left" width="100px" height="170px">
    <span>abc</span>
    <span>def</span>
    <span>ghi</span>
</marquee>

Live example: http://jsfiddle.net/8uqatjed/

But consider that the marquee tag should NOT be used, as it is obsolete and not anymore supported by most recent browsers releases:

So, if I've understood good your request, this could be the reason it's not working well for you.

cereal 1,524 Nearly a Senior Poster Featured Poster

@davidbcn

Hi, open your own thread to get responses.

cereal 1,524 Nearly a Senior Poster Featured Poster

It depends: do you want to lock out the user from his profile or allow him to enter and display a message that invites him to renew the membership?

Above query is checking if user exists and if expired, but it will not work fine if typed user is wrong. To work fine this approch would require at least two queries:

  • the first query to check if user exists, by searching the username and eventually the password (if you want to notify only the owner);
  • the second query to check if expired based on user id got from the previous query.

To use only one query then, yes, you can use PHP, but I suggest DateTime as this is more simple:

# the $row variable carries the query result
$expires_at = new DateTime($row['expires_at']);
$today      = new DateTime('now');

if($expires_at < $today)
    echo 'Your account expired, please <a href="/renew.php">renew here.</a>';

else
{
    # enable session & redirect to profile
    $_SESSION['logged'] = true;
    $_SESSION['user_data'] = array('username', 'and', 'so', 'on');
    header('Location: http://site.tld/profile');
}

If it still does not work, please show an example of date returned by the database table.

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to set quotes around the value you want to search, otherwise COURT will be interpreted as a column name. So:

$sql = "SELECT full_name, tdoc_number, race, facility FROM inmate_board WHERE type = 'COURT'";

By using exceptions and the try/catch block, you would have seen the error:

Error Code: 42S22
Error Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'COURT' in 'where clause'
cereal 1,524 Nearly a Senior Poster Featured Poster

The number sign # acts like a comment in MySQL, in your case it will affect the query by returning all the rows instead of selecting by id. But this should not return the Invalid argument supplied for foreach() error, it seems that your query returned boolean FALSE.

To understand what is going on, use a try/catch block and exceptions. For example:

$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

try {
    $stmt = $connection->prepare("SELECT full_name FROM customers where id = ?");
    $stmt->execute(array($_POST['id']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
}
catch(Exception $e)
{
    print 'Error Code: ' . $e->getCode() . PHP_EOL;
    print 'Error Message: ' . $e->getMessage() . PHP_EOL;
    die();
}

print $row['full_name'];

Note: using die() and printing error messages directly in page is good in development stage, while in production you should append all error codes and messages to the error log file and return a simple message, without details.

Documentation:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the set_rules() method requires three arguments:

  • field name
  • label
  • rules

See documentation at:

So your rules would look like:

$this->form_validation->set_rules('email', 'email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password','required');
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, the undefined offset is probably given by:

$rawData[$i + $backdate]

Check if the index key exists:

$key = $i + $backdate;
if(array_key_exists($key, $rawData))
    $pTimeseries[$i][1] = $rawData[$key][0];
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, use prepared statements, start from here:

Look at the first example in the first link, I'm not converting the code directly for you, because it's more important that you understand how it works and how the methods/functions are used.

cereal 1,524 Nearly a Senior Poster Featured Poster

what's that 'as dummy_3 ' ??

It's '' as dummy_3 i.e. empty space defined with an alias, it will return an empty column, for example:

select '' as dummy_3;
+---------+
| dummy_3 |
+---------+
|         |
+---------+
1 row in set (0.00 sec)

It can be used as workaround when quering tables with column mismatch.

diafol commented: Nice explanation +15
cereal 1,524 Nearly a Senior Poster Featured Poster

And how would you know which result sets belongs to what? If you're expecting a row for each table, then you could add empty columns:

select id, name, lastname from users where id = 1
union all
select user_id, email, '' as dummy_3 from addresses where user_id = 1;

But in this case the join solution is better.

shany0786 commented: what's that 'as dummy_3 ' ?? +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Something like this will fit?

<?php

    $tests = file("php://stdin", FILE_IGNORE_NEW_LINES);

    foreach($tests as $test)
    {
        for($i = 0; $i <= $test; $i++)
        {
            $size   = 9283412;
            $isEven = (($test % 2) != 0 ? true : false);

            if($test == 0)
            {
                $size = 1;
                break;
            }

            elseif($isEven)
                $size *= 2;

            else
                $size += 1;
        }

        print $size . PHP_EOL;
    }

Giving an input file:

php script.php < data.txt

With a number each line:

1
2
3
0
4
17

Returns:

18566824
9283413
18566824
1
9283413
18566824

Is this you're trying to accomplish?

Besides, you can get the same results by avoiding the inner loop:

foreach($tests as $test)
{
    $size   = 9283412;
    $isEven = (($test % 2) != 0 ? true : false);

    if($test == 0)
        $size = 1;

    elseif($isEven)
        $size *= 2;

    else
        $size += 1;

    print $size . PHP_EOL;
}

Because $test ($_tmp in your script), it never changes, for example: if even it will be even for all his loops.

Aeonix commented: Solution. +4
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, have you tried this?

The SDK is contained in the lib/ folder in the zip file so copy lib/ into your project and name it dropbox-sdk/ and include it in your app:

    require_once "dropbox-sdk/Dropbox/autoload.php";

Source: https://www.dropbox.com/developers-v1/core/sdks/php

cereal 1,524 Nearly a Senior Poster Featured Poster

Good, with fputcsv() you can do:

$list = $sql->fetchAll(PDO::FETCH_ASSOC);
$f = fopen('file.txt', 'w');

foreach($list as $line)
    fputcsv($f, $line);

fclose($f);

You need fetchAll() because you need an array, fetch() instead will return a single row of the result set. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
it happens because fwrite() is outside the loop and will write the last vallue assigned at $line. Use fputcsv():

Look at the first example, it does what you need.

cereal 1,524 Nearly a Senior Poster Featured Poster

Model name is BooksModel (plural), in that method controller you're calling BookModel, (singular). Bye ;)

tejpatel commented: this might have happened +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

it happens because both tables will return the same column name tableA_id, since you're fetching as assoc, it will create an array in which the first index will be rewritten by the second column value. You see how it works by playing this:

<?php

    $stmt = $conn->prepare("select * from tableA left outer join tableB on tableA.tableA_id = tableB.tableA_id where tableB.tableA_id is null");
    $stmt->execute();
    $result = $stmt->fetchAll();

    print_r($result);

It will return both numeric and assoc index keys, so tableA_id index key will be empty, the numeric [0] and [4], instead, will show the current values i.e. 2 and null. Here's an example:

Array
(
    [0] => Array
        (
            [tableA_id] => 
            [0] => 2
            [title] => pneumonia
            [1] => pneumonia
            [month] => jan
            [2] => jan
            [tableB_id] => 
            [3] => 
            [4] => 
            [correspondence_ref] => 
            [5] => 
            [date_received] => 
            [6] => 
            [date_dispatched] => 
            [7] => 
        )

You see how tableA_id index is appearing only once? If you define the columns you want to return and use a column alias, then you can solve this issue.

So instead of select * do:

select tableA.tableA_id as tableAID, tableA.month, tableA.month, tableB.*

Note that if you were going to define a different WHERE condition (IS NOT NULL instead of IS NULL), you would not notice this error, as also the other columns would return populated. Check the examples here:

cereal 1,524 Nearly a Senior Poster Featured Poster

MySQL needs single quotes:

P. that should not make difference:

or I'm missing something? :)

@blueguy777

if you using mysql_* then try to add mysql_error() after the query to catch the error, for example:

$q = mysql_query($m_query) or die(mysql_error());

Show also what would be the end query.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you are enclosing the query into single quotes:

$a = 'apples';
$b = 'oranges';

So in order to append another variable you have to use the dot operator:

$c = 'list '. $b . ' and ' .$a;

Basically is this. You have done that when defining the table name ($job_id), so the query would turn to:

$m_query = 'Insert into '.$job_id.'(`mobile`,`routeID`,`status`) values ('.$mobile.','.$routeID.',"Sent")';

Note:

  • the space after the into keyword
  • also 'Sent' becomes "Sent"

But it will not work, unless $mobile and $routeID are integers, if those are strings, then you have to add quotes (double quotes in this case):

$m_query = 'Insert into '.$job_id.'(`mobile`,`routeID`,`status`) values ("'.$mobile.'","'.$routeID."',"Sent")';

This can be refactored with double quotes:

$m_query = "insert into {$job_id} (`mobile`, `routeID`, `status`) values ('{$mobile}', '{$routeID}', 'Sent')";

In any case, you really don't want to create a query like this, you want to use prepared statements, as explained here:

cereal 1,524 Nearly a Senior Poster Featured Poster

@gentlemedia

I completely agree with you, for me it's better to work with classes as suggested by you and diafol in previous posts. I went ahead with OP requests to show him how it can be done, even if this is not the best solution. Anyway, this is what I intended:

In this case the title attribute would work as substitute of a class or an id attribute, since those are not applicable to a <link> tag.

gentlemedia commented: Nice one :) +5
cereal 1,524 Nearly a Senior Poster Featured Poster

I can write it for you, it's easy. You have to:

  • click the download link on the right side of this page:
    https://github.com/PHPMailer/PHPMailer
  • create a directory in your server and upload the uncompressed archive
  • then create this script:

    <?php
    
    require './PHPMailerAutoload.php';
    
    $mail = new PHPMailer;
    
    $mail->isSMTP();
    $mail->WordWrap    = 50;
    $mail->SMTPDebug   = 3;
    $mail->Debugoutput = 'html';
    $mail->SMTPAuth    = TRUE;
    
    # Office265 credentials
    $mail->Host        = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';
    $mail->Username    = 'username@domain.tld';
    $mail->Password    = 'password';
    
    # set FROM header
    $mail->From        = 'username@domain.tld';
    $mail->FromName    = 'website';
    
    # set TO header
    $mail->addAddress('recipient@domain.tld', 'Recipient Name');
    
    $mail->Subject     = 'Test';
    $mail->Body        = 'Hello World!';
    
    echo ! $mail->send() ? 'Error: ' . $mail->ErrorInfo : 'Success!';
    

and simply save the file to your server, remember to adjust the require call, in order to start autoload file.

Then load the above script from browser: with correct credentials you should see a log similar to my previous post, else you will see the errors. Note this line:

$mail->Host = 'tsl://smtp.office365.com:587;ssl://smtp.office365.com:995';

it is defining TSL or SSL connection which use different port numbers, these should be 587 and 995. The first line of the log, should tell you what is used, in my case it starts with SSL, while if I try only TSL it fails immediately.

The log should give you some information about what is going wrong: credentials, port numbers, IP and, if problem is on yours end, help you to fix Wordpress configuration.

If in doubt you can post the result here.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

try to change port number to 465, it works fine for me.

Gribouillis commented: spot-on +14
cereal 1,524 Nearly a Senior Poster Featured Poster

If you're using the resize() method of the image library, it happens because of:

Image_lib class already loaded. Second attempt ignored.

You can see that from the log of CodeIgniter. I don't know if they added something to avoid this problem, I just use this solution:

see the last comment, in practice when you load the library you assign a dynamic name and use that to load the new instance:

private function _resize($source, $filename, $num = 1)
{
    $config['image_library']  = 'gd2';
    $config['source_image']   = $source;
    $config['new_image']      = FCPATH . 'thumbs/' . $filename;
    $config['create_thumb']   = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width']          = 75;
    $config['height']         = 50;

    $instance = 'image_lib_'.$num;

    $this->load->library('image_lib', $config, $instance);

    return $this->$instance->resize();
}

Then, you can insert this _resize() method in the for loop:

$this->_resize($upload_data['full_path'], $upload_data['file_name'], $i);

And it should work fine.

Just a note: imagine what can happen if N users start to upload images at the same time, they could kill the server, since this is an intensive task for the CPU, if you can, you should consider to go asynchronous and let the server start just few resize processes (no more than a resize process per core). It can be done with tools like beanstalkd or gearman:

This requires access to a ssh session and the privilege to install apps. See example here:

shany0786 commented: thnks for reply plz see below it's not working yet +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, check the documentation:

the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.

But mysqlclient does not support Python 3.5:

MySQL-3.23 through 5.5 and Python-2.7, 3.3-3.4 are currently supported. PyPy is supported.

So, I think, you have to downgrade to Python 3.4 or try the MySQL Connector/Python which according to documentation:

It may not support the most recent releases of Django.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

Sorry but on update and add functions you're setting $_SESSION['msg'], on message() instead you're dealing with $_SESSION['message'], is that a mistype?

I built a simple test and works fine:

<?php

    session_start();

    function message()
    {
        if(isset($_SESSION['msg']))
        {
            $output = "<div class=\"msg\">{$_SESSION['msg']}</div>";
            unset($_SESSION['msg']);
            return $output;
        }
    }

    function insert()
    {
        $r = mt_rand(1, 2);

        if($r > 1)
            $_SESSION['msg'] = 'Failed @ '. time();

        else
            $_SESSION['msg'] = 'Success @ '. time();
    }

    if($_SERVER['REQUEST_METHOD'] == 'POST')
        insert();

?>
<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>

    <?php print message(); ?>

    <hr>

    <form method="post">
        <input type="submit">
    </form>

    <hr>

    <a href=".">refresh</a>

</body>
</html>
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you should move on public_html only the files that are in the public folder of your laravel application, all the other files should be placed in the parent directory, so that are not accessible by a browser.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can set the result type for fetch_all() which is defined by MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH as explained here and as shown in my previous example:

In any of these cases it will return an array. If for example you would access only the first entry, then you would write:

$rows = $name->fetch_all(MYSQLI_ASSOC);
echo $rows[0]['full_name'];

When using fetch_all() is it fetching the whole table?

It returns only what you have defined in your query, but you get an array with the entire result set. The fetch_array() method instead returns only the first row of the result set, by looping as shown in the example you access all the other entries.

You can test it, do simply:

$row = $name->fetch_assoc();
echo $row['full_name'];

# move internal pointer to get another row
$name->data_seek(2);

$row = $name->fetch_assoc();
echo $row['full_name'];

The same is done, automatically, by the loop.

cereal 1,524 Nearly a Senior Poster Featured Poster

o/

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you have to fetch the results, fetch_all() will return the entire result set:

$result = $name->fetch_all(MYSQLI_ASSOC);
print_r($result);

While fetch_array() will return one row, and in order to get the orders you have to loop:

while($row = $name->fetch_assoc()) {
    echo $row['full_name'];
}

Or move the internal pointer through field_seek() . Check the mysqli_result class for more methods:

cereal 1,524 Nearly a Senior Poster Featured Poster

Uh, yes you need the correct privilege in order to perform these changes. Open a ticket with the hosting company and point them to the error message you got from mysqli_connect(), they can fix the issue.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, check this link: http://php.net/migration55

P.S. You should read also migrations notes for 5.3 and 5.4, to see what else has changed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Beautiful upgrade Dani!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, run:

SELECT `User`, `Password`, length(`Password`) FROM mysql.user;

The length should be 41, if you get 16 it means that the user is still using the old password system and it needs to be updated. And you have to make sure the system variable old_password is set to 0, otherwise using PASSWORD() will return the same result of OLD_PASSWORD().

More information at:

Adjust the links according to your current MySQL version, as there could be some differences.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you could use json or base64, but what happens if you want to search throught collected data? It would be unusable without extra processing. Why don't you normalize the array? Look at section 8 of this tutorial:

cereal 1,524 Nearly a Senior Poster Featured Poster

Same for me, I ran:

SELECT * FROM `playertimes` WHERE `runtime` BETWEEN 100 AND 200 ORDER BY `runtime` ASC LIMIT 20

And returns in perfect order.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I suggest you to print the contents of the POST request to see what is actually sent to the script, so on top of the progress.php file simply put:

<?php

    if($_POST)
        die("<pre>". print_r($_POST, true) ."</pre>");

At the moment I see you have duplicated input fields like Progressid, by doing this you get unwanted behaviour as one of the two fields will be overwritten, the same happens with the input field named Position. It is not only related to the name attribute (which, is some cases is allowed: arrays name="Progressid[]" or in radio buttons) but it is also related to the id attribute, that must be unique over the page. In your case Progressid is set two times in the form and the format ProgressidN (where N is $i++) is set in both tabs.

In addition, but not related to the form submission, you're applying the name attribute to div tags, this is not allowed.

Also, you're initializing the session (session_start()) multiple times: set it only once on top of the page, otherwise you won't get the values of $_SESSION, unless the session is already initialized on the portion of code you did not posted.

And finally on lines 3, 119 and 177 you wrote:

<input type="hidden" name="Progressid" id="Progressid" value="<?php echo $row['Progressid']; ?>">

But I don't see when you set $row for the first time. I think the problem is here: after line 3, on line 19 you have:

while($row = mysql_fetch_array($r))

The function mysql_fetch_array() will overwrite …

cereal 1,524 Nearly a Senior Poster Featured Poster

As I wrote in previous post:

About the headers: if not defined, Node will set implicit headers, but you should always set a status [code|message] response:

https://nodejs.org/api/http.html#http_response_statuscode

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, does it work now?

Applying the end() method after you write the response body is mandatory. About the headers: if not defined, Node will set implicit headers, but you should always set a status [code|message] response:

By the way, you last attempt wasn't working for you because the send() method does not exists in the http module.

cereal 1,524 Nearly a Senior Poster Featured Poster

You should be able to start and stop it as a daemon:

sudo service mongod start
sudo service mongod stop
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, in order to write a response you have to send an header and then call end():

res.writeHead(200, {'Content-Type': 'text/html'});
res.write('2working');
res.end();

Also, probably mistype, on console log you wrote that it listens on port 8080, but it's executing on 8889.

Docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, read this guide:

In particular follow the instructions for Ubuntu 13.10+, you have to include the configuration file into the server, the guide refers to Apache.

Anyway, I prefer to install it directly from source, to get the latest version. Just uncrompress to a directory in /var/www/, assign a local domain (for example phpmyadmin.sql) and follow the setup guide from PHPMyAdmin.

cereal 1,524 Nearly a Senior Poster Featured Poster

It does not work because you are trying to style an external link loaded by the iframe tag.

So, remove this:

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d97183.46594409156!2d-79.98050049999999!3d40.431368449999994!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x8834f16f48068503%3A0x8df915a15aa21b34!2sPittsburgh%2C+PA%2C+USA!5e0!3m2!1sen!2sid!4v1438937398399" width="1000" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

Replace it with:

<div id="map"></div>

And apply CSS rules to #map, from there you can define the size of the map, for example:

#map {
    height:450px;
    width:1000px;
}
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you have defined the init function and the array, but you are not applying the array to the map, so change this:

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -34.397, lng: 150.644},
    zoom: 8
  });
}

To:

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: -34.397, lng: 150.644},
    zoom: 8
  });
  map.setOptions({styles: styleArray});
}

And it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster
pritaeas commented: ROFL +14
cereal 1,524 Nearly a Senior Poster Featured Poster

@broj1

Hi, I've seen that in Magento, for internationalization, it's a refer to gettext _():

cereal 1,524 Nearly a Senior Poster Featured Poster

so we can use RowID for uniquely identifying the records right ?

Depends how much uniqueness needs to be extended: on SQLite it will be unique over the table, in Oracle it will be unique over the database and in PostgreSQL is not encouraged because:

The oid type is currently implemented as an unsigned four-byte integer. Therefore, it is not large enough to provide database-wide uniqueness in large databases, or even in large individual tables. So, using a user-created table's OID column as a primary key is discouraged. OIDs are best used only for references to system tables.

You wrote:

Can we use indexes instead of using keys for identifying unique records

An index can be defined by a primary key or by a unique key, both can be based by single or multiple columns. So no, at least at my knowledge and in reference to MySQL, you cannot define an index without defining which keys will be part of it.

or can declare trigger for each unique record?

A possible but expensive task, at least in MySQL, because it would require a full scan of the table each time you need to insert or update something. An index will speed up most of these operations.

cereal 1,524 Nearly a Senior Poster Featured Poster

Interviewer said you need not to use any key in the table either that is a unique key or any natural key.

So nothing explicitly defined in the creation table statement, correct?

Maybe the question refers to implict keys like ROWID (available on Oracle & SQLite), or OIDs (Object Identifier in PostgreSQL) which are set by default by the database. However these are not available in all databases, like for example in MySQL.