与MAMP的mysql命令行

时间:2017-04-01 13:42:38

标签: macos mamp

我意识到我无法在我的macosx 10.5.8上安装mysql workbench而我没有其他解决办法,只能在操作系统上使用mysql命令行。以下是我开始在MAMP上使用mysql命令行的方法,如果有人发现有用我回答我自己的问题是有帮助的。

1 个答案:

答案 0 :(得分:2)

class product {

  private $id;
  private $name;
  private $color;
  private static $last_id;

  function __construct( $name, color $color ){
    $this->last_id++;
    $this->id=$this->last_id;
    $this->name = $name;  
    $this->color = $color;
  }

  function getName(){
    return $this->name;
  }

  function getColor(){
    return $this->color;
  }  

  function getId(){
    return $this->id;
  }
}

class color {

  private $id;
  private $hexCode;
  private static $last_id;

  function __construct( $hexCode ){
    $this->last_id++;
    $this->id=$this->last_id;
    $this->hexCode = $hexCode;
  }

  function getId(){
    return $this->id;
  }

}


class productMapper{

  function persist( product $product ){

    // persist query 
    $someQueryBuilder->insert('products')->set('name',$product->getName())->set('refColor',$product->getColor()->getId()); 

    $product->setId( $someQueryBuilder->getInsertId() );

  }

}


$color = new color('FFCC00');
$product = new product( 'table', $color );


$productMapper = new productMapper();
$productMapper->persist( $product );