本文整理匯總了PHP中DboSource::name方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::name方法的具體用法?PHP DboSource::name怎麽用?PHP DboSource::name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::name方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
/**
* SQL file header
*
* @param $datasource
* @return string
*/
function _createSqlDumpHeader($datasource)
{
$sql = array();
$sql[] = $this->hr(0);
$sql[] = '-- ' . $this->message;
$sql[] = '-- generated on: ' . date('Y-m-d H:i:s') . ' : ' . time();
$sql[] = $this->hr(0);
$sql[] = '';
if (preg_match('/^mysql/i', $this->DataSource->config['driver'])) {
$sql[] = 'use ' . $this->DataSource->name($this->DataSource->config['database']) . ';';
}
if (!empty($this->DataSource->config['encoding'])) {
$sql[] = 'SET NAMES ' . $this->DataSource->value($this->DataSource->config['encoding']) . ';';
}
return $this->out($sql);
}
示例2: testFieldParsing
/**
* testFieldParsing method
*
* @return void
*/
public function testFieldParsing()
{
$this->Model = new TestModel();
$result = $this->Dbo->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`");
$expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`");
$expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created");
$expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`");
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test');
$this->assertEquals(array('round( (3.55441 * fooField), 3 ) AS test'), $result);
$result = $this->Dbo->fields($this->Model, null, 'ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating');
$this->assertEquals(array('ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'), $result);
$result = $this->Dbo->fields($this->Model, null, 'ROUND(Rating.rate_total / Rating.rate_count,2) AS rating');
$this->assertEquals(array('ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'), $result);
$result = $this->Dbo->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name");
$expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name");
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1");
$expected = array('2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`', "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`");
$expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`");
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post');
$expected = array('`Post`.`id`', '`Post`.`client_id`', '`Post`.`name`', '`Post`.`login`', '`Post`.`passwd`', '`Post`.`addr_1`', '`Post`.`addr_2`', '`Post`.`zip_code`', '`Post`.`city`', '`Post`.`country`', '`Post`.`phone`', '`Post`.`fax`', '`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`', '`Post`.`created`', '`Post`.`updated`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Other');
$expected = array('`Other`.`id`', '`Other`.`client_id`', '`Other`.`name`', '`Other`.`login`', '`Other`.`passwd`', '`Other`.`addr_1`', '`Other`.`addr_2`', '`Other`.`zip_code`', '`Other`.`city`', '`Other`.`country`', '`Other`.`phone`', '`Other`.`fax`', '`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`', '`Other`.`created`', '`Other`.`updated`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array(), false);
$expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'COUNT(*)');
$expected = array('COUNT(*)');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->Dbo->name('sum_unread_buyer'));
$expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'name, count(*)');
$expected = array('`TestModel`.`name`', 'count(*)');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'count(*), name');
$expected = array('count(*)', '`TestModel`.`name`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'field1, field2, field3, count(*), name');
$expected = array('`TestModel`.`field1`', '`TestModel`.`field2`', '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('dayofyear(now())'));
$expected = array('dayofyear(now())');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('MAX(Model.field) As Max'));
$expected = array('MAX(`Model`.`field`) As Max');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('Model.field AS AnotherName'));
$expected = array('`Model`.`field` AS `AnotherName`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('field AS AnotherName'));
$expected = array('`field` AS `AnotherName`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('TestModel.field AS AnotherName'));
$expected = array('`TestModel`.`field` AS `AnotherName`');
$this->assertEquals($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Foo', array('id', 'title', '(user_count + discussion_count + post_count) AS score'));
$expected = array('`Foo`.`id`', '`Foo`.`title`', '(user_count + discussion_count + post_count) AS score');
$this->assertEquals($expected, $result);
}
示例3: name
/**
* Prepares field names to be quoted by parent
*
* @param string $data
* @return string SQL field
*/
function name($data)
{
if (is_string($data)) {
$data = str_replace('"__"', '__', $data);
}
return parent::name($data);
}
示例4: name
/**
* Prepares field names to be quoted by parent
*
* @param string $data
* @return string SQL field
*/
function name($data)
{
return parent::name(str_replace('"__"', '__', $data));
}