jeudi 13 août 2015

Amazon Aurora RDS unable to use import file . Access denied for user in Mysql Workbench

I have created an amazon aurora rds database instance and successfully connected with Mysql Workbench with master user.Queries are also working fine, But i do not have all the privileges necessary to perform file import operations. I have read many documentations and threads related to this but am not able to GRANT privileges to Master user. Step by step guidance will be highly appreciated. Thank You.



via Chebli Mohamed

Real Time Notification

I want to show notification into admin panel if any user insert a new ticket. that means if a new row inserted into ticket table then on admin panel show a notification and ticket count will be increased.

I cant understand How to do it. if any example available of laravel or CI or PHP then please share.

I am using laravel 4.2



via Chebli Mohamed

Arduino to MySQL via phpmyadmin

I'm trying to record arduino readings to a MySQL DB on a NetSol hosted MySQL DB via a WiFi shield. I'm using phpmyadmin (NetSol's interface) to manage the DB.

I'm using a variation of this Sketch to make it all happen: http://ift.tt/1TyQ1Qx

Everything is great until it gets to the "void postData{" piece. I know the IP of the phpmyadmin MySQL DB but it is not connecting. How can I get the arduino to connect to the DB?

I've been working on this for weeks and I'm three seconds from throwing my computer against a wall! This is very frustrating! I'm at the end of my rope and I hope you appreciate that I've exhausted just about every other learning option...help!

I'm using modified PHP files that the Sketch author recommended as well. I can see the empty table on my site. I just can't get the data into the DB.



via Chebli Mohamed

Getting rows of a day by timestamp, Day/Minute of certain pattern

id   name     quantity    timestamp
1    item1     2         2015-06-01 20:00:00
2    item2     5         2015-06-01 22:30:00
3    item3     2         2015-06-02 20:00:00
4    item4     7         2015-06-02 20:30:00
5    item5     9         2015-06-02 21:30:00

This is an example database, 'timestamp' is in datetime format and contains varying values. Note that the table contains various date and time data. How do i get all the rows of one day and of certain minute(above eg: 30) only, eg how can i select all the rows with timestamp 2015-06-01 **:30:00, here ** = hour any help, thanks.



via Chebli Mohamed

How to install MySQL Http Plugin on Windows 7?

I have MySQL 5.7 installed on my Windows 7 system. Can anyone help me with the instructions to install the experimental Http Plugin?



via Chebli Mohamed

HttpURLConnection to use connect to php Error:Server returned HTTP response code: 500 for URL:

I'm using java to read from an excel file and put that data into variables, then send those variables to php where it will get processed and inserted into a mysql database. The database wont allow me to directly insert into the database, so I'm doing a work-around. I get this error when I run my program. "Server returned HTTP response code: 500 for URL:" This happens when it gets to the conn.getOutputStream(); If someone knows how i can fix this on the server side please let me know so that I can try to fix it

String link="http://website/directory/file.php";
            String data  = URLEncoder.encode("fName", "UTF-8")
                    + "=" + URLEncoder.encode(fName, "UTF-8");
            data += "&" + URLEncoder.encode("lName", "UTF-8")
                    + "=" + URLEncoder.encode(lName, "UTF-8");
            data += "&" + URLEncoder.encode("SID", "UTF-8")
                    + "=" + URLEncoder.encode(SID+"", "UTF-8");
            data += "&" + URLEncoder.encode("email", "UTF-8")
                    + "=" + URLEncoder.encode(email, "UTF-8");
            data += "&" + URLEncoder.encode("major", "UTF-8")
                    + "=" + URLEncoder.encode(major, "UTF-8");
            data += "&" + URLEncoder.encode("year", "UTF-8")
                    + "=" + URLEncoder.encode(year, "UTF-8");
            data += "&" + URLEncoder.encode("isPaid", "UTF-8")
                    + "=" + URLEncoder.encode(isPaid+"", "UTF-8");
            data += "&" + URLEncoder.encode("isNational", "UTF-8")
                    + "=" + URLEncoder.encode(isNational+"", "UTF-8");
            URL url = new URL(link);
            //Did the CookieHandler just in case the server wants them
            CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);

            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write( data );
            System.out.println("data was passed");
            wr.flush();
            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuilder sb = new StringBuilder();
            String line = null;

            // Read Server Response I'm using echo . ie: echo "yes";
            while((line = reader.readLine()) != null)
            {
                sb.append(line);
                break;
            }
            System.out.println(sb.toString());
        }
            if(sb.toString().equals("yes"))
            {
                ttlAffected++;
            }
            else if(sb.toString().equals("no"))
            {
                System.out.println("Student ID: "+array.get(rowOn).getSID()+" already exists");
                fail.add(array.get(rowOn).getSID());
            }
            else if(sb.toString().equals("error"))
            {
                System.out.println("An unknown error occured");
                fail.add(array.get(rowOn).getSID());
            }
            else
            {
                System.out.println("IDk what happened        "+  sb.toString());
            }

Also, here is the php side

    <?php
    $con=mysqli_connect("host","username","password","database");
    if (mysqli_connect_errno($con))
{
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$_SESSION['fName']=$_POST['fName'];
$_SESSION['lName']=$_POST['lName'];
$_SESSION['SID']=$_POST['SID'];
$SID=$_SESSION['SID']
$_SESSION['email']=$_POST['email'];
$_SESSION['major']=$_POST['major'];
$_SESSION['year']=$_POST['year'];
$_SESSION['isNational']=$_POST['isNational'];
$_SESSION['isPaid']=$_POST['isPaid'];


$sql ="SELECT * FROM Registered_Members15 WHERE SID='$SID'";
$result = mysqli_query($com,$sql);
if(mysqli_num_rows($result)==0)
{
                                        $query_member = "INSERT INTO Events15(id,SID) VALUES (?, ?)";
                                        $stmt_member = mysqli_prepare($con,$query_member);
                                        mysqli_stmt_bind_param($stmt_member, "si" , $_SESSION['email'], $_SESSION['SID']);
                                        mysqli_stmt_execute($stmt_member);
                                        $affected_rows_mem = mysqli_stmt_affected_rows($stmt_member);
                                        mysqli_stmt_close($stmt_member);

                                        $query = "INSERT INTO Registered_Members15(ID,first_name,last_name,SID,email,paid_chapter,paid_national,major,year)  VALUES (NULL,?, ?, ?, ?, ?, ?, ?, ?)";
                                        $stmt = mysqli_prepare($con, $query);
                                        mysqli_stmt_bind_param($stmt, "ssisiiss", $_SESSION['fName'], $_SESSION['lName'], $_SESSION['SID'], $_SESSION['email'], $_SESSION['isPaid'], $_SESSION['isNational'], $_SESSION['major'], $_SESSION['year']);
                                        mysqli_stmt_execute($stmt);

                                         $affected_rows = mysqli_stmt_affected_rows($stmt);
                                        if($affected_rows == 1 && $affected_rows_mem == 1)
                                        {
                                                echo "yes";
                                        }
                                        else
                                        {
                                            echo "error";
                                        }
}else{
    echo "no";
}

mysqli_close($con);

?>

I believe this is all right but I do want to ask if someone could check if i did something wrong.



via Chebli Mohamed

My sql , join tables with dynamic fields

i want to use @mm as global scope var and use it value in second and 3rd tables.(even dummy field to join ) anyone has idea? thanks

select a.totalL,b.totalR, @mm:=c.plac from users as c inner join (SELECT SUM(amnt) as totalL ,type,@mm as MN FROM gb WHERE amnt> 0 AND plac_id LIKE concat(@mm,'1%')

AND (DATE(date1) BETWEEN DATE('2015-06-23 00:00:00') AND DATE('2015-08-13 23:59:59') ) AND type=10 ) as a on c.plac = a.MN inner join (SELECT SUM(amnt) as totalR ,type,@mm as MN FROM gb WHERE amnt> 0 AND plac_id LIKE concat(@mm,'2%') AND (DATE(date1) BETWEEN DATE('2015-06-23 00:00:00') AND DATE('2015-08-13 23:59:59') ) AND type=10 )as b on a.type = b.type



via Chebli Mohamed

How can I implement my own interface for OpenID that uses a MySQL Database instead of In memory storage

So I'm trying to use the OpenID package for Golang, located here: http://ift.tt/1DOG62f

In the _example it says that it uses in memory storage for storing the nonce/discoverycache information and that it will not free the memory and that I should implement my own version of them using some sort of database.

My database of choice is MySQL, I have tried to implement what I thought was correct (but is not, does not give me any compile errors, but crashes on runtime)

My DiscoveryCache.go is as such:

package openid

import (
    "database/sql"
    "log"
    //"time"

    _ "http://ift.tt/1kNPaoi"
    "http://ift.tt/1DOG62i"
)

type SimpleDiscoveredInfo struct {
    opEndpoint, opLocalID, claimedID string
}

func (s *SimpleDiscoveredInfo) OpEndpoint() string { return s.opEndpoint }
func (s *SimpleDiscoveredInfo) OpLocalID() string  { return s.opLocalID }
func (s *SimpleDiscoveredInfo) ClaimedID() string  { return s.claimedID }

type SimpleDiscoveryCache struct{}

func (s SimpleDiscoveryCache) Put(id string, info openid.DiscoveredInfo) {
    /*
       db, err := sql.Query("mysql", "db:connectinfo")
         errCheck(err)
         rows, err := db.Query("SELECT opendpoint, oplocalid, claimedid FROM discovery_cache")
         errCheck(err)

       was unsure what to do here because I'm not sure how to 
       return the info properly 
    */

    log.Println(info)
}

func (s SimpleDiscoveryCache) Get(id string) openid.DiscoveredInfo {
    db, err := sql.Query("mysql", "db:connectinfo")
    errCheck(err)

    var sdi = new(SimpleDiscoveredInfo)
    err = db.QueryRow("SELECT opendpoint, oplocalid, claimedid FROM discovery_cache WHERE id=?", id).Scan(&sdi)
    errCheck(err)

    return sdi

}

And my Noncestore.go package openid

import (
    "database/sql"
    "errors"
    "flag"
    "fmt"
    "time"

    _ "http://ift.tt/1kNPaoi"
)

var maxNonceAge = flag.Duration("openid-max-nonce-age",
    60*time.Second,
    "Maximum accepted age for openid nonces. The bigger, the more"+
        "memory is needed to store used nonces.")

type SimpleNonceStore struct{}

func (s *SimpleNonceStore) Accept(endpoint, nonce string) error {

    db, err := sql.Open("mysql", "dbconnectinfo")
    errCheck(err)

    if len(nonce) < 20 || len(nonce) > 256 {
        return errors.New("Invalid nonce")
    }

    ts, err := time.Parse(time.RFC3339, nonce[0:20])
    errCheck(err)

    rows, err := db.Query("SELECT * FROM noncestore")
    defer rows.Close()

    now := time.Now()
    diff := now.Sub(ts)

    if diff > *maxNonceAge {
        return fmt.Errorf("Nonce too old: %ds", diff.Seconds())
    }

    d := nonce[20:]

    for rows.Next() {
        var timeDB, nonce string
        err := rows.Scan(&nonce, &timeDB)
        errCheck(err)

        dbTime, err := time.Parse(time.RFC3339, timeDB)
        errCheck(err)

        if dbTime == ts && nonce == d {
            return errors.New("Nonce is already used")
        }
        if now.Sub(dbTime) < *maxNonceAge {
            _, err := db.Query("INSERT INTO noncestore SET nonce=?, time=?", &nonce, dbTime)
            errCheck(err)
        }
    }

    return nil

}

func errCheck(err error) {
    if err != nil {
        panic("We had an error!" + err.Error())
    }
}

Then I try to use them in my main file as:

import _"http://ift.tt/1HKaaqv"

var nonceStore = &openid.SimpleNonceStore{}
var discoveryCache = &openid.SimpleDiscoveryCache{}

I get no compile errors but it crashes

I'm sure you'll look at my code and go what the hell (I'm fairly new and only have a week or so experience with Golang so please feel free to correct anything)

Obviously I have done something wrong, I basically looked at the NonceStore.go and DiscoveryCache.go on the github for OpenId, replicated it, but replaced the map with database insert and select functions

IF anybody can point me in the right direction on how to implement this properly that would be much appreciated, thanks! If you need anymore information please ask.



via Chebli Mohamed

How to make my index page load images without reloading page, every time user logs out, whose locations are stored in database?

My index page, that is login and signup page has 3 images, whose locations are stored in database, loads those images automatically if the page is refreshed. For example, when I open the index page as a user for login, the images are loaded and shown without any problem. But when I logout, the images disappear, which actually should have been there. Further if I refresh the page, they are shown again.

So the only problem that I can see is related with REFRESH/RELOAD. I have used session functions for logging out. When a user logs out, the session is destroyed and index page appears, because I used the header(""); function, which contains the address of index page. So when user clicks log out, it opens the index page, without refreshing it (I assume so). So images are not shown. They need a page relaod/refresh for appearing.

How to solve this problem?



via Chebli Mohamed

Xampp Mysql and Apache not Working - How to backup database

I'm having trouble with my Mysql and Apache server here for a week already. Tried to look for every possible solutions in the internet like changing ports and everything. Still no luck. I would like to reinstall Xampp, the problem is, I have important databases which do not have any backups yet. Is there a way to backup these databases without having my apache and mysql started?



via Chebli Mohamed

Update row with minimum value sql

I have this table:

-----------------------
summonerId | timestamp
-----------------------
253222     | 14395235091096
929112     | 14395235091056
(...)

I want to update the row with the lower timestamp but I can't, when I do this

UPDATE summoners_shell 
SET 
summonerId = ".$s.",
timestamp = ".$time." 
WHERE timestamp = (SELECT MIN(timestamp))

It updates all rows! Why? How do I do what I want?



via Chebli Mohamed

send email to user register using php

I'm building a registration form using MySQL to store data and work perfectly. when users register will be sent a verification email to activate user accounts. the problem is not the verification email sent to the email users but user data and the activation code can get into mysql.

Here code for insert.php

<?php

//panggil file config.php untuk menghubung ke server
include('config.php');

//tangkap data dari form
$nama = $_POST['nama'];
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$alamat = $_POST['alamat'];
$telp = $_POST['telp'];
$password = mysql_real_escape_string($_POST['password']);

// regular expression for email check
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/';
if(preg_match($regex, $email))
{ 
$password=md5($password); // encrypted password
$activation=md5($email.time()); // encrypted email+timestamp
$count=mysql_query("SELECT id_user FROM user WHERE email='$email'");
// email check
if(mysql_num_rows($count) < 1)
{
$query = mysql_query("insert into user (nama,email,telp,password,alamat,username,activation) VALUES('$nama', '$email', '$telp', '$password', '$alamat', '$username', '$activation')") or die(mysql_error());

if ($query) {
    header('location:index.php');
}
// sending email
include ('sendEmail.php');
$to=$email;
$subject="Email verification";
$body='Hi, <br/> <br/> Silakan verifikasi dengan klik link di bawah ini. <br/> <br/> <a href="http://localhost/LAPAN-Project/verify.php?code=' . $activation . '">Verifikasi</a>';

sendEmail($to,$subject,$body);
$msg= "Registration successful, please activate email."; 
}
else
{
$msg= 'The email is already taken, please try new.'; 
}

}
else
{
$msg = 'The email you have entered is invalid, please try again.'; 
}

// HTML Part
//}
?>

and here the code sendEmail.php

<?php
function sendEmail($to,$subject,$body)
{
   require ('class.phpmailer.php');
$from       = "me@kumistebal.web.id";
$mail       = new PHPMailer();
$mail->IsSMTP(true);            // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "ssl://smtp.gmail.com"; // SMTP host
$mail->Port       =  465;                    // set the SMTP port
$mail->Username   = "*********@gmail.com";  // SMTP  username
$mail->Password   = "*********";  // SMTP password
$mail->SetFrom($from, 'From Name');
$mail->AddReplyTo($from,'From Name');
$mail->Subject    = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($email, $to);
if(!$mail->Send())
        echo "Mailer Error: " . $mail->ErrorInfo;
    else
        echo "Message has been sent";
}    

?>

Does anyone have any idea how to do?



via Chebli Mohamed

Raw mysql queries with all the clause without writing every attribute in play framework (java)

So In Java (play framework) I want to write a raw MySQL query to get all attributes from myTable with a WHERE clause (and possibly other clauses)

I am using RawSqlBuilder. If I use unparsed, then I Cannot have any conditional clause (such as where). See example below

String sql = "SELECT * FROM myTable"; // here i CANNOT add a WHERE atOne = 5 since I am using unparsed. It doesn't work

RawSql rawSql =   
                 RawSqlBuilder  
                    .unparsed(sql)
                    .columnMapping("attOne", "attOne")
                    .columnMapping("attTwo", "attTwo")
                    .create();  

Query<myTableModel> query = Ebean.find(myTableModel.class);
query.setRawSql(rawSql);

List<myTableModel> list = query.findList();

However, if I use parsed, then I CAN use my WHERE clause but I Cannot use * after my Select. Instead of * I must write ALL the attributes names that I want to get. But this is VERY inconvenient. What if I have 25 attributes? example below

String sql = "SELECT attOne, attTwo FROM myTable WHERE attOne = 5"; // as you can see here, I MUST put attOne, attTwo else it won't work

RawSql rawSql =   
                 RawSqlBuilder  
                    .parsed(sql)
                    .columnMapping("attOne", "attOne")
                    .columnMapping("attTwo", "attTwo")
                    .create();  

Query<myTableModel> query = Ebean.find(myTableModel.class);
query.setRawSql(rawSql);

List<myTableModel> list = query.findList();

My question is, how can I use * along with WHERE clause and map it to my myTableModel

If I can't, is there a way to access sql db with raw queries in java?



via Chebli Mohamed

Multiple markers at this line help meeee

helpm me :(

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //Menemukan lokasi tombol di activity_main.xml
    Button tombol = (Button) findViewById(R.id.button1);

    //Menangkap Klik pada Tombol
    tombol.setOnClickListener(new OnClickListener() {

 @Override
 public void onClick(View arg0) {
     //TODO Auto-generated method stub
 Intent Intentku = new Intent(MainActivity.this,AktivitasBaru.class);
 startActivity(Intentku);

 } <<<<<<<<<< eror    

    }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

Multiple markers at this line - Syntax error, insert ")" to complete Expression - Syntax error, insert ";" to complete Statement - Syntax error, insert "}" to complete ClassBody



via Chebli Mohamed

Syntax error in MySQL 5.5

I did this simple SQL Query succesfuly from PHP Admin 4 years ago with SQL 5.1. Now I try the same in SQL 5.5 for my new project and getting a syntax error. Mayby somebody can help me to get in the game again.Thanks

SQL query:

CREATE TABLE `mfl` (
`id` INT NOT NULL,
`rank` MEDIUMINT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM 

MySQL said: Documentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE = MYISAM' at line 5



via Chebli Mohamed

subtract 1 month from a DB column symfony2

I am trying to write a query in order to get all the data whose date is greater than 11 months and less than 12 month. I have tried the query below which returns date difference in days. Is there any way I can check on months ??

$qb ->select("pj,DATE_DIFF(CURRENT_TIME(), pj.date) as dt)
    ->from("PrevJbs", "pj");



via Chebli Mohamed

PHP Script is connecting to database but will not return a table value despite being connected.

        <!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="http://ift.tt/1P3hXG4">
        <script src="http://ift.tt/1JJRCNi"></script>
        <link rel="stylesheet" href="http://ift.tt/1I7E37E">
    </head>
    <body>
        <!-- Always shows a header, even in smaller screens. -->
        <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
          <header class="mdl-layout__header">
            <div class="mdl-layout__header-row">
              <!-- Title -->
              <span class="mdl-layout-title">Forum</span>
              <!-- Add spacer, to align navigation to the right -->
              <div class="mdl-layout-spacer"></div>
              <!-- Navigation. We hide it in small screens. -->
              <nav class="mdl-navigation mdl-layout--large-screen-only">
                <a class="mdl-navigation__link" href="">Default Subforum2</a>
              </nav>
            </div>
          </header>
          <div class="mdl-layout__drawer">
            <span class="mdl-layout-title">Forum</span>
            <nav class="mdl-navigation">
              <a class="mdl-navigation__link" href="">Browse Subforums</a>
              <a class="mdl-navigation__link" href="">Search For Post</a>
            </nav>
          </div>
          <main class="mdl-layout__content">
            <div class="page-content">
                <!-- Your content goes here -->
                <?php
                    include("dbforforum.php");
                    $subForum = "";
                    $results = $mysqli->query("SELECT * FROM `SubForumList`");
                    echo $results;
                    for ($i = 0; $i < $results->num_rows; $i++)
                    {
                        $results->data_seek($i);
                        $row = $results->fetch_assoc();
                        $subForum = $row['Name'];
                        echo $subForum;
                        echo $subForum;
                    }
                ?>
            </div>
          </main>
        </div>
    </body>
</html>

I'm trying to echo HTML within PHP the row 'subForum' of my SQL table $row['subForum'] every time this loop goes through, however, for some reason it is not connecting.

Even in dbforforum.php, my database config file, it is showing that it connected successfully:

<?php

$mysqli = new mysqli("localhost", "root", "", "Forum");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";

?>

I am very, very confused by this. Any help is appreciated.

Note: I recently switched to Mac from Windows (not my choice), and have therefore gone from WAMP to MAMP. Not sure if this has to do with anything.



via Chebli Mohamed

Rails: Autocreate associated records as soon as parent record is saved

I'm trying to automatically create records in a child table as soon as a parent record is saved but I'm stuck and need a help how to do this.

So my table hierarchy of the Orgs is like Org->Brand->Restaurant (eg. Americana(Org) -> KFC(Brand) ->San Francisco(Restaurant)).

A Brand has many menus and Menu belongs to a Brand. Now I want to cascade menu for each Restaurant from the Brand's menu because I want to be manage price by the Restaurant. In order to do that, I created a 'local_menus' table which contains restaurant_id and menu_id so that I don't have to duplicate some data and changes in the local_menus will not be affected to its parent.

The question is how do I auto create records in 'local_menus' as soon as a parent menu is created. To be more specific, when I create a menuA, the same menu needs to be created automatically for all the restaurants under the brand. Appreciate your support.

MODELS:

class LocalMenu < ActiveRecord::Base
  belongs_to :restaurant
  belongs_to :menu
end

class Menu < ActiveRecord::Base
    has_many :local_menus
    belongs_to :brand
end

class Restaurant < ActiveRecord::Base
    has_many :menus, through: :local_menus
end

TABLES:

local_menus
    t.integer  "restaurant_id",  limit: 4
    t.integer  "menu_id",        limit: 4
    t.boolean  "active_status",    limit: 1
    t.boolean  "instock_status", limit: 1
    t.integer  "price",          limit: 4


menus
    t.integer  "restaurant_id",      limit: 4
    t.string   "name",               limit: 255
    t.integer  "price",              limit: 4
    t.integer  "brand_id",           limit: 4
    t.integer  "category_id",        limit: 4
    t.text     "description",        limit: 65535
    t.boolean  "active_status",      limit: 1
    t.date     "start_date"
    t.date     "end_date"

restaurants
    t.string   "name",          limit: 255
    t.string   "name_kana",     limit: 255
    t.integer  "price",         limit: 4
    t.boolean  "active_status", limit: 1
    t.integer  "brand_id",      limit: 4



via Chebli Mohamed

How can I use query in router.php of codeigniter?

I have a list of router such as:

$route['mobile'] = 'parrent_list';
$route['tables'] = 'parrent_list';
$route['laptop'] = 'parrent_list';
$route['gamer'] = 'parrent_list';

My router.php have about 100 row. I dont't want set it manual. So i want know how can I use query in router to get my categories in database. Example:

require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get( 'categories' )->where( 'parrent_id', 0 );
$result = $query->result();
foreach( $result as $row )
{
    $route[ $row->slug ]                 = 'parrent_list;
    $route[ $row->slug.'/:any' ]         = 'parrent_list;

}

I try but it don't work. Thanks all.



via Chebli Mohamed

Laravel 5 successful seed but nothing return from database

I successfully seeded data in mysql table but nothing return from the database in view. I've tried to drop and re-migrate tables multiply times and it did not work.

I also tried to enrolled on my website and it worked! The view could return me the user information I enrolled on the web but not those I seeded. Meanwhile, when I checked in mysql, the database returned me those data I seeded but not the data I enrolled.

I am really confused about this problem and wish someone could enlighten me on this problem, thanks.



via Chebli Mohamed