We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

in model, selectReadConnection's param is fixed or custom?


class Robots extends Phalcon\Mvc\Model
{
    public function selectReadConnection($intermediate, $bindParams, $bindTypes)
    {
     ....

params ($intermediate, $bindParams, $bindTypes) is fixed or custom?

how to set the param value?



368

Follow tutorial https://docs.phalcon.io/en/latest/reference/models.html

But constants are wrong in documentation, correct are BIND_PARAM_NULL BIND_PARAM_INT BIND_PARAM_STR BIND_PARAM_BOOL BIND_PARAM_DECIMAL BIND_SKIP Related to : https://docs.phalcon.io/en/latest/api/Phalcon_Db_Column.html



98.9k

That function is called to select the correct connection used to read, there you receive the parameters that were passed in the query:

$robots = Robots::find(['type = ?0', 'bind' => ['Virtual'], 'bindTypes' => [Column::BIND_PARAM_STR]);


17.8k

ok,thanks . i test it after a while

now, the selectReadConnection is fixed method within phalcon framework, i want to say , selectReadConnection method not full intro in document , and i find the api \Phalcon\Mvc\Model not have this method .

but have these method in api

public Phalcon\Mvc\Model setReadConnectionService (string $connectionService)

Sets the DependencyInjection connection service name used to read data

public Phalcon\Mvc\Model setWriteConnectionService (string $connectionService)

Sets the DependencyInjection connection service name used to write data

public string getReadConnectionService ()

Returns the DependencyInjection connection service name used to read data related the model

public string getWriteConnectionService ()


17.8k

selectReadConnection must be a connection?

i want to split a big table to many table , but in one database. how can i do ?



17.8k

Array
(
    [models] => Array
        (
            [0] => Test
        )

    [tables] => Array
        (
            [0] => test
        )

    [columns] => Array
        (
            [test] => Array
                (
                    [type] => object
                    [model] => Test
                    [column] => test
                    [balias] => test
                )

        )

    [where] => Array
        (
            [type] => binary-op
            [op] => =
            [left] => Array
                (
                    [type] => qualified
                    [domain] => test
                    [name] => id
                    [balias] => id
                )

            [right] => Array
                (
                    [type] => literal
                    [value] => 1
                )

        )

)

parame $intermediate 's print_r value.

this post not a question , Facilitate others to use



98.9k

selectReadConnection is not implemented by the extension, the extension checks if the method has been defined by the developer in a model and calls it, this is the same behavior for event callbacks (beforeSave, beforeDelete) etc.

Actually, this funcionality is not intended to implement vertical sharding, you can use this method to implement horizontal sharding, this means, return a connection name according to the current search parameters, rather than return a table name.



17.8k

ok ,thanks