本文整理汇总了PHP中RedBeanPHP\QueryWriter\AQueryWriter::camelsSnake方法的典型用法代码示例。如果您正苦于以下问题:PHP AQueryWriter::camelsSnake方法的具体用法?PHP AQueryWriter::camelsSnake怎么用?PHP AQueryWriter::camelsSnake使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\QueryWriter\AQueryWriter
的用法示例。
在下文中一共展示了AQueryWriter::camelsSnake方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: via
/**
* Registers a association renaming globally.
*
* @param string $via type you wish to use for shared lists
*
* @return OODBBean
*/
public function via($via)
{
$this->via = AQueryWriter::camelsSnake($via);
return $this;
}
示例2: count
/**
* Counts the number of beans of type $type.
* This method accepts a second argument to modify the count-query.
* A third argument can be used to provide bindings for the SQL snippet.
*
* @param string $type type of bean we are looking for
* @param string $addSQL additional SQL snippet
* @param array $bindings parameters to bind to SQL
*
* @return integer
*
* @throws SQLException
*/
public function count($type, $addSQL = '', $bindings = array())
{
$type = AQueryWriter::camelsSnake($type);
if (count(explode('_', $type)) > 2) {
throw new RedException('Invalid type for count.');
}
try {
return (int) $this->writer->queryRecordCount($type, array(), $addSQL, $bindings);
} catch (SQLException $exception) {
if (!$this->writer->sqlStateIn($exception->getSQLState(), array(QueryWriter::C_SQLSTATE_NO_SUCH_TABLE, QueryWriter::C_SQLSTATE_NO_SUCH_COLUMN))) {
throw $exception;
}
}
return 0;
}
示例3: link
/**
* Creates a N-M relation by linking an intermediate bean.
* This method can be used to quickly connect beans using indirect
* relations. For instance, given an album and a song you can connect the two
* using a track with a number like this:
*
* Usage:
*
* $album->link('track', array('number'=>1))->song = $song;
*
* or:
*
* $album->link($trackBean)->song = $song;
*
* What this method does is adding the link bean to the own-list, in this case
* ownTrack. If the first argument is a string and the second is an array or
* a JSON string then the linking bean gets dispensed on-the-fly as seen in
* example #1. After preparing the linking bean, the bean is returned thus
* allowing the chained setter: ->song = $song.
*
* @param string|OODBBean $type type of bean to dispense or the full bean
* @param string|array $qualification JSON string or array (optional)
*
* @return OODBBean
*/
public function link($typeOrBean, $qualification = array())
{
if (is_string($typeOrBean)) {
$typeOrBean = AQueryWriter::camelsSnake($typeOrBean);
$bean = $this->beanHelper->getToolBox()->getRedBean()->dispense($typeOrBean);
if (is_string($qualification)) {
$data = json_decode($qualification, TRUE);
} else {
$data = $qualification;
}
foreach ($data as $key => $value) {
$bean->{$key} = $value;
}
} else {
$bean = $typeOrBean;
}
$list = 'own' . ucfirst($bean->getMeta('type'));
array_push($this->{$list}, $bean);
return $bean;
}
示例4: testCamel2Snake
/**
* Test camelCase to snake_case conversions.
*
* @return void
*/
public function testCamel2Snake()
{
asrt(AQueryWriter::camelsSnake('bookPage'), 'book_page');
asrt(AQueryWriter::camelsSnake('FTP'), 'ftp');
asrt(AQueryWriter::camelsSnake('ACLRules'), 'acl_rules');
asrt(AQueryWriter::camelsSnake('SSHConnectionProxy'), 'ssh_connection_proxy');
asrt(AQueryWriter::camelsSnake('proxyServerFacade'), 'proxy_server_facade');
asrt(AQueryWriter::camelsSnake('proxySSHClient'), 'proxy_ssh_client');
asrt(AQueryWriter::camelsSnake('objectACL2Factory'), 'object_acl2_factory');
asrt(AQueryWriter::camelsSnake('bookItems4Page'), 'book_items4_page');
asrt(AQueryWriter::camelsSnake('book☀Items4Page'), 'book☀_items4_page');
}