Welcome Guest, Not a member yet? Register   Sign In
Showing product name instead of product id in the URL.
#6

(This post was last modified: 07-04-2018, 12:23 AM by Pertti.)

(07-03-2018, 12:40 AM)mianaliasjad Wrote: Then according to this, i have to make product name primary key in my table of database.
can't i just say that i search from the database with integer id but show name in the url?

You can change your database query.

Assuming you select it by ID right now.

PHP Code:
$product $this->db
    
->where('id'1)
    ->
limit(1)
    ->
get('product'); 

You then specify what field you want to select by

PHP Code:
$product $this->db
    
->where('name''Honor-10')
    ->
limit(1)
    ->
get('product'); 

You don't have to change your DB primary key, it still can be ID, but you should index the name field.
Reply


Messages In This Thread
RE: Showing product name instead of product id in the URL. - by Pertti - 07-04-2018, 12:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB